开发者

htaccess rules losted when directory exists

this is my code at .HTACCESS file in my web server:

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
R开发者_StackOverflowewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

This code works well, but when a directory exists the website redirect to Index of (Apache directory browsing):

For example:

  1. http://www.mywebsite.com/XXXX This redirects to the URL http://www.mywebsite.com/XXXX and the page show information about XXXX. (Directory XXXX doesn't exists)

  2. Directory ZZZZ exists and http://www.mywebsite.com/ZZZZ redirects to Index of (Apache directory browsing)

Finally, the question is how to redirect as 1. example.


RewriteCond %{REQUEST_FILENAME} !-d

This line disables rewriting for existing directories. Simply remove it if you always want to rewrite.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜