views:

282

answers:

2

I have a CakePHP site that contains a vanilla Wordpress installation. It lives in /app/webroot/blog/. The problem I'm having is a strange one.

I have the site configured, through mod rewrite, to redirect all requests to /app/webroot/blog to /blog/. The reason for this is that Wordpress was either throwing errors or displaying no content when the user visited it via the app/webroot path and it works just fine if you visit it at /blog/. It would also redirect the user to /app/webroot/blog if they attempted to visit /blog without a trailing slash, so we added that as well. Here are the mod_rewrite rules we're using to accomplish this:

RewriteRule    ^blog$ blog/ [L]
RewriteRule    ^app/webroot/blog/(.*)$ blog/$1 [L]

When the user attempts to visit the admin section of Wordpress but is not authenticated, it sends them to the /wp-login.php page and sends along a query string parameter called redirect_to that contains the URL the user was originally trying to access before being asked to authenticate. This URL contains the full path (/app/webroot/blog/...) instead of just going to /blog, even if the original request was a page within /blog. If the user successfully authenticates, then the user is sent back to the login page as though nothing happened (no error messages, etc.).

I would assume that the second mod_rewrite rule listed above would rectify the issue, but it doesn't seem to be.

I hope I've explained this thoroughly, please let me know if I can provide additional information that I may have forgotten. Thanks!

+1  A: 

have you tried checking wordpress options in wp database. there are two options you should make sure that are correct. siteurl and home. both should be http://yoursite.com/blog

Funky Dude
Yes, these values are both set correctly.
inkedmn
A: 

What's your document root directory? Make app/webroot/ your document root directory and you won't need any additional rewrite rules, because CakePHP's default rewrite rules already have rules for existing files and directories:

So your /app/webroot/index.php will be you application entry point with address .../ ,

and app/webroot/blog/ will be wordpress entry point with address .../blog/

Default rewrite rules are enough for this configuration:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d # this will go to your blog dir, if it exists
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L] # this is CakePHP app
Sergei