简体   繁体   中英

cakephp2 with wordpress in a subfolder

I am currently using wordpress and cakephp together on one apache server. Cakephp is installed in the root and wordpress is in a subfolder2. I can access wordpress by going to http://domain.com/blog/ and that works great. I would like to move this to be in a subfolder/ virtual directory in cakephp. So the url would be http://domain.com/subfolder/blog

The subfolder is cakephp virtual directory that does not exist. I have tried to ignore this by adding a condition to main htaccess file in cakephp (see below). It does not seem to work. Is this possible to ignore one virtual directory and pass to wordpress. Creating an actual folder will break the site as cakephp will no longer be able to handle the requests.

RewriteCond %{REQUEST_URI} !^/subfolder/blog/(.*)

I was able to use this: Can I disable rewrite for specific directory?

# ignore application_test for any rewrites
RewriteRule ^subfolder(/|$) - [NC,L]

I was able to route all wordpress request through htaccess and bypass cakephp. I installed wordpress in the /app/webroot/subfolder2 and got it working as normal.

I then added this rule above app webroot rules to handle the routing. Htaccess intercepts the rule for wordpress before cake has a chance to access it. The subfolder2 is not part of any virtual directory and is an actual directory in webroot. However subfolder is a virtual directory in cake.

# route to wordpress instead of cakephp
RewriteRule ^subfolder/blog(.*)$ /subfolder2/$1 [NC,L]

# route to cakephp
RewriteRule    ^$ app/webroot/    [L]
RewriteRule    (.*) app/webroot/$1 [L]  

I then manually updated the site_url, and home fields in the blog_options table in mysql so that it could route to the new virtual directory. It seems to work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM