我在我的网站的根文件夹下使用以下htaccess规则删除文件扩展名并在末尾添加尾部斜杠。但是,我想从根文件夹htaccess规则中排除子目录/ sub-dir /。我试图添加另一个htaccess到/ sub-dir /文件夹,并将RewriteOptions inherit
或RewriteEngine Off
放入文件中,但它们都不起作用。从根文件夹中的htaccess规则排除子目录
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]
任何建议,非常感谢。
感谢
你看看这里? http://stackoverflow.com/a/13842523/2696690 – Winter 2014-10-22 03:24:41
@Winter是的。我试过了。我认为它不起作用,因为我的htaccess文件的规则是不同的。 – Webnerdoz 2014-10-22 03:39:51