我的.htaccess文件中有8行重写规则.我需要从这些规则中排除服务器上的两个物理目录,以便它们可以访问.现在所有请求都发送到index.php文件.
要排除的目录:"admin"和"user".
所以http请求:http://www.domain.com/admin/不应该传递给index.php文件.
ErrorDocument 404 /index.php?mod=error404
Options FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.domain\.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
RewriteRule ^([^/] )/([^/] )\.html$ index.php?lang=$1&mod=$2 [L]
RewriteRule ^([^/] )/$ index.php?lang=$1&mod=home [L]
Run Code Online (Sandbox Code Playgroud) 我在我的网站的根文件夹下使用htaccess规则以删除文件扩展名并在末尾添加尾部斜杠.但是,我想从根文件夹htaccess规则中排除子目录/ sub-dir /.我试图将另一个htaccess添加到/ sub-dir /文件夹并放入RewriteOptions inherit或RewriteEngine Off放在文件中,但它们都不起作用.
RewriteEngine On
RewriteBase /
# redirect from non-www to www
RewriteCond %{HTTP_HOST} ^mywebsite.com.au$ [NC]
RewriteRule ^(.*)$ http://www.mywebsite.com.au/$1 [R=301,L]
RewriteCond %{REQUEST_URI} ^/index.php$
RewriteRule ^(.*)index.php$ http://www.mywebsite.com.au/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{THE_REQUEST} ^GET\ /[^?\s]+\.php
RewriteRule (.*)\.php$ /$1/ [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*)/$ $1.php [L]
# Remove trailing slash:
RewriteRule (.*)/$ $1 [L]
# Now test without the trailing slash:
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule . %{REQUEST_FILENAME}.php [QSA,L]
Run Code Online (Sandbox Code Playgroud)
任何建议都非常感谢.
谢谢