开发者

Using mod_rewrite to accept several DirectoryIndex variants [closed]

Closed. This question is off-topic. It is not currently accepting answers.

Want to improve this question? Update the question so it's on-topic for Stack Overflow.

Closed 10 years ago.

Improve this question

How to redirect it as follows?:

mysite.com -> mysite.com/index.php

mysite.com/index.php -> mysite.co开发者_C百科m/index.php

mysite.com/index -> mysite.com/index.php

mysite.com/main.php -> mysite.com/index.php

mysite.com/main -> mysite.com/index.php

Same with .html extension (ie. mysite.com/index.html -> mysite.com/index.php)


Try these rules:

RewriteRule ^/$ /index.php
RewriteRule ^/(main|index)(\.(php|html))?$ /index.php

If you want to use these rules in the .htaccess file in the document root directory, remove the leading slash from the patterns.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜