RewriteRule (.*) index.php

Can you explain this?

link|improve this question

40% accept rate
feedback

migrated from stackoverflow.com Feb 11 '10 at 8:24

This question came from our site for professional and enthusiast programmers.

3 Answers

up vote 1 down vote accepted

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

link|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
feedback

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.

link|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
feedback

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

link|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
feedback

Your Answer

 
or
required, but never shown

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