1

我有这些工作重写规则:

# Allow access to assets folder from plugins folders
RewriteRule ^app/plugins/(.+)/assets - [L]

# forbid access to files and folders under app
RewriteRule ^app/.*$ - [L,F]

# rewrite to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?action=$1 [L,QSA]

现在我想从这些规则中排除位于http://www.mywebsite.com/wordpress/下的所有内容......因此我添加了一个新的重写条件:

...
# rewrite to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^\/wordpress\/ [NC]
RewriteRule ^(.*)$ index.php?action=$1 [L,QSA]

但它不起作用。当我尝试访问这样的内容时: http ://www.mywebsite.com/wordpress/contact-us/

它会将我重定向到 index.php ...

任何帮助将非常感激。

4

1 回答 1

1

好的,我终于发现了这一切的问题:事实上,我没有注意到我的 /wordpress 目录中存在 .htaccess 文件。因此,在我的根目录的 .htaccess 中,我在所有其他规则之上添加了这条规则:

RewriteRule ^wordpress - [L]

然后在 wordpress 目录的 .htaccess 中,我有这些规则:

RewriteBase /wordpress/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]

我不知道是否一切都经过优化,但它可以工作!

于 2012-12-28T18:18:03.823 回答