RewriteRule (.*) index.php

Can you explain this?


This rule matches requests to all possible URL paths and rewrites them to index.php.

| improve this answer | |
  • Hi Gumbo. Thanks for the answer. Can you also tell me what is this? RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L] – Vivek Chandraprakash Feb 9 '10 at 18:41
  • @Vivek Chandraprakash: The E flag sets an environment variable. In this case the value of the HTTP header field Authorization is assigned to the environment variable HTTP_AUTHORIZATION. – Gumbo Feb 9 '10 at 19:10

This points any web address given to index.php. The first argument is a regular expression (look it up if you don't know) and the second is of course the page to redirect to. Note that the redirect is on the server side and so isn't visible to the outside user, and this is therefore how websites make their addresses easier to read.

| improve this answer | |
  • thanks. can you tell me what this means? RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L] – Vivek Chandraprakash Feb 9 '10 at 18:46
  • This will explain it: besthostratings.com/articles/http-auth-php-cgi.html – Stephen Feb 9 '10 at 18:48

The very first result on google for "RewriteRule" is this. It very clearly explains the syntax.

(.*) is a regular expression which matches all incoming requests. It's basically saying any request that comes in, behave as if the user requested index.php

| improve this answer | |
  • thanks for the reply. can you tell me what thsi means? RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L] – Vivek Chandraprakash Feb 9 '10 at 18:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.