Wordpress:阻止特定目录的mod_rewrite规则

时间:2013-04-11 03:52:43

标签: php apache .htaccess mod-rewrite cakephp-2.0

我正在尝试将CakePHP应用程序安装在与Wordpress站点相同的目录中。 CakePHP应用程序只有几个控制器,所以我认为这应该可以通过添加一些RewriteCond来实现。不幸的是,以下/.htaccess文件无法正常工作:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

#start my additions
RewriteCond %{REQUEST_URI} !^/admin
RewriteCond %{REQUEST_URI} !^/tests
RewriteCond %{REQUEST_URI} !^/users
RewriteCond %{REQUEST_URI} !^/css/
RewriteCond %{REQUEST_URI} !^/js/
#end my additions

RewriteRule . /index.php [L]
</IfModule>

# END WordPress

#CakePHP rules
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_URI} !^/$
RewriteRule (.*) app/webroot/$1 [L]

出于某种原因,找不到Wordpress样式表:

GET http://example.dev/wp-content/themes/sow3/style.css?1365621024 404 (Not Found)

1 个答案:

答案 0 :(得分:1)

看起来像cakephp规则正在重写静态内容。尝试为重写添加一些条件:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/$
RewriteRule (.*) app/webroot/$1 [L]

或者

RewriteCond %{REQUEST_URI} !^/wp-content
RewriteCond %{REQUEST_URI} !^/wp-admin
RewriteCond %{REQUEST_URI} !^/wp-includes
RewriteCond %{REQUEST_URI} !^/$
RewriteRule (.*) app/webroot/$1 [L]