开发者

Using mod_rewrite to accept several DirectoryIndex variants [closed]

开发者 https://www.devze.com 2023-01-19 19:31 出处:网络
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. 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

精彩评论

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

关注公众号