我有一个CakePHP安装在一个子文件夹在我的服务器,我想安装该子文件夹在其他应用程序:
I have a CakePHP installation in a sub folder in my server, I want to install another application inside that subfolder:
root/public_html/subfolder/cake/
root/public_html/subfolder/app/
等。现在我需要安装有一个自定义应用程序:
etc. now I need a custom application installed there:
root/public_html/subfolder/my_custom_application/
我有这样的事情在我的.htaccess:
I have something like this in my .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
我
如何配置它从排除my_custom_application文件夹规则?
How can I configure it to exclude the "my_custom_application" folder from that rules?
我尝试这样做:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule ((?!my_custom_application).*) app/webroot/$1 [L]
</IfModule>
不过,我得到这样的:
But I get this:
Error: The requested address '/y_custom_application' was not found on this server.
在此先感谢。
Thanks in advance.
毛。
我遇到了同样的问题,因为你。我挣扎,但最后发现一些工作。 的(我回答,因为答案上面,我没有工作,但这种做法)。的
I ran into the same problem as you. I struggled, but finally found something that worked. (I'm replying because the answer above didn't work for me, but this did).
我的目录结构:
root/public_html/app/
root/public_html/lib/
root/public_html/plugins/
root/public_html/vendors/
root/public_html/directory_to_exclude/
我加入CakePHP的默认路由是什么:
RewriteCond %{REQUEST_URI} !^/directory_to_exclude/(.*)
实际上,我需要让人们单独访问子文件夹(因为有一个单独的应用程序)。此外,在我的情况,我提供从根目录下的CakePHP的应用程序在默认情况下。 因此,这里就是我的CakePHP的2.x的htaccess的样子:
Effectively, I needed to allow people to access the subfolder separately (since that has a separate application). Also, in my case, I'm serving a CakePHP application by default from the root directory. So here's what my CakePHP 2.x htaccess looks like:
更新的.htaccess(这为我的作品)
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/directory_to_exclude/(.*)
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
在你的情况,我知道你需要这个子文件夹中工作;这里是我的调整htaccess的我没有机会来测试这一点,但我相信这(或一些接近)将工作:
In your case, I understand you need this to work in a subfolder; here's my adjusted htaccess I didn't have a chance to test this, but I believe this (or something close) will work:
最终产品(一个子文件夹)
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/subfolder/directory_to_exclude/(.*)
RewriteRule ^$ subfolder/app/webroot/ [L]
RewriteRule (.*) subfolder/app/webroot/$1 [L]
</IfModule>