开发者

Rewriting www.mydomain.com/index.php to www.mydomain.com

I have found two different methods to redirect from index.php / index.html to the domain. Both seem to work; none of them ends in a loop:

RewriteEngine On
RewriteRule ^index\.(php|html?)$ http://www.martin-thoma.de/terminplaner/ [R=301,L]

and

RewriteEngine On
RewriteCond %{IS_SUBREQ} false
RewriteRule ^index\.(php|html?)$ htt开发者_StackOverflowp://www.martin-thoma.de/terminplaner/ [R=301,L]

edit: here is another rule:

RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.(html?|php)\ HTTP/
RewriteRule ^index\.(html?|php)$ http://www.martin-thoma.de/terminplaner/ [R=301,L]

Where is the difference between these three methods of rewriting? What should I use?

Here is a part of the manual:

IS_SUBREQ Will contain the text "true" if the request currently being processed is a sub-request, "false" otherwise. Sub-requests may be generated by modules that need to resolve additional files or URIs in order to complete their tasks.


Surely your .htaccess in not in the http://www.martin-thoma.de/terminplaner/ directory. So, they are working :)

Anyways, you see that, the first one is fairly simple. And, it works. For the second one, the IS_SUBREQ is always false (assuming that no other rewrite rule is translating something else to index.php or index.html. So, its working also.

This page will help you to understand when the IS_SUBREQ is true. This page has has example.

If you do not have any other rule, you can very safely use the first one (without RewriteCond)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜