开发者

htaccess rules losted when directory exists

开发者 https://www.devze.com 2023-03-02 01:28 出处:网络
this is my code at .HTACCESS file in my web server: RewriteEngine On RewriteBase / RewriteRule ^index\\.php$ - [L]

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

精彩评论

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