Set up CakePHP in a subdirectory; Wordpress is installed in the root

断了今生、忘了曾经 提交于 2019-12-31 02:30:09

问题


I have been searching for a solution for 2 hours but nothing seems to work... here is my problem:

I have WordPress installed in the root (var/www). So by going to http://www.geekderek.com, I see my wordpress site.

I put CakePHP in a subdirectory var/www/cakephp. I want to be able to see my CakePHP app by going to: www.geekderek.com/cakephp.

However, currently this url just returns a Wordpress page saying "Content not found."

I believe this problem can be solved by modifying .htaccess in my root directory. So here is my .htaccess: http://pastebin.com/sXJTRstB

As you can see, I added this line to the default WP .htaccess file:

RewriteRule    ^cakephp(/(.*))?$ cakephp/app/webroot/$1    [QSA,L]

However, for some reason this doesn't seem to work.

Could anyone please tell me what is wrong?? Thank you so much!


回答1:


I have simmilar setup, that my cake app is in subdirectory, my root .htaccess has this rewrite rule:

RewriteRule ^cakephp/(.*)$ /cakephp/$1 [L,QSA]

All the rest is handled with the regular cakephp setup.

my /cakephp/app/webroot/.htaccess:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]

hope this works for you too :)




回答2:


thanat's answer almost worked for me. i just had to edit the RewriteBase to read

RewriteBase /cakephp

and make sure apache conf allowed my root directory to override its previous options

<Directory "/my/root/dir">
AllowOverride All
</Directory>

but then again, my app dir lies outside the DocumentRoot set by apache. and the cakephp dir is actually the webroot itself. so my dir structure is as follows

/my/root
/my/root/app  #cake's app dir without webroot
/my/root/dir  #apache DocumentRoot (your wordpress is here)
/my/root/dir/cakephp  #cake's webroot

also make sure to edit /my/root/dir/cakephp/index.php so it knows where the app and cake's library dirs are.



来源:https://stackoverflow.com/questions/12947396/set-up-cakephp-in-a-subdirectory-wordpress-is-installed-in-the-root

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!