emersonthis
emersonthis

Reputation: 33378

Wordpress: prevent mod_rewrite rules for specific directories

I am trying to install a CakePHP app in the same directory as a Wordpress site. The CakePHP app only has a couple controllers, so I think this should be possible by adding a few RewriteConds. Unfortunately the following /.htaccess file isn't working correctly:

# 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]

For some reason, the Wordpress stylesheets aren't getting found:

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

Upvotes: 2

Views: 274

Answers (1)

Jon Lin
Jon Lin

Reputation: 143886

It looks like the cakephp rules are rewriting the static content. Try adding some conditions for the rewrite:

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

Or

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

Upvotes: 1

Related Questions