排除来自CakePHP的应用程序根文件夹 [英] Exclude a root folder from CakePHP app
问题描述
我想从蛋糕(根文件夹的应用程序)不包括第一级目录,因为它应该有不同的应用程序。
I am trying to exclude a first level directory from Cake (root folder app), as it should hold a different app.
/保存应用程序
/显影/保持该应用的测试版本
/development/ holds the tested version of the app
的目录结构:
公共文件夹
.htaccess [modified]
app
.htaccess [unmodified]
webroot
.htaccess [unmodified]
index.php [unmodified]
...
...
lib
Cake
...
development
app
webroot
index.php [dumps $_SERVER for test purposes]
所以,我的发展格局还没有一个应用程序内(也.htaccesses),如果我的根。htaccess的作品只是为了测试。
So, my development structure still doesn't have an app inside (nor .htaccesses), just to test if my root .htaccess works.
这是我的根的.htaccess的修改:
This is my modification of the root .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/development.*
RewriteRule (.*) - [L]
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
会发生什么:
/开发/显示开发文件夹的阿帕奇指数
/development/ shows the apache index of development folder
/开发/应用/显示应用程序文件夹的阿帕奇指数
/development/app/ shows the apache index of app folder
/开发/应用程序/ webroot的显示根应用程序(要求被捕获,尽管发展URL匹配)。
/development/app/webroot shows the root app (request is captured in spite of the development url match).
/开发/应用/ Webroot公司应该告诉我我的/development/app/webroot/index.php文件,对吧?
/development/app/webroot SHOULD show me my /development/app/webroot/index.php file, right?
什么是地狱我在这里丢失?
What the hell am I missing here?
推荐答案
这竟然是我的服务器上的一个古怪的问题。
This turned out to be an oddball bug on my server.
生成的的.htaccess
它的工作原理现在:
The resulting .htaccess
which works now is:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/development(?:$|/)
RewriteRule ^$ app/webroot/ [L]
RewriteCond %{REQUEST_URI} !^/development(?:$|/)
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
不知什么原因对我来说,如果我通过命令行通过SSH连接到我的用户帐户和编辑的.htaccess文件,这是行不通的!
For reasons unknown to me, if I SSH'd to my user account and edited the .htaccess files through the command line, it wouldn't work!
当我上传了相同的文件(通过SFTP),它开始正常工作。
When I uploaded the same files (via SFTP), it started working properly.
我使用的cPanel(11.34.1)在CentOS(5.9)。
I am using cPanel (11.34.1) on CentOS (5.9).
另外一个例子:如果你希望的忽略的上一个CakePHP安装多个子文件夹,您可以使用此模式:
Another example: if you wish to "ignore" multiple sub-folders on a CakePHP installation, you can use this pattern:
<IfModule mod_rewrite.c>
RewriteEngine on
# /development, /version1.5 and /version1.8 directories
# they all hold independent apps
# or completely non-cake-related content
RewriteCond %{REQUEST_URI} !^/(?:development|version1\.5|version1\.8)(?:$|/)
RewriteRule ^$ app/webroot/ [L]
RewriteCond %{REQUEST_URI} !^/(?:development|version1\.5|version1\.8)(?:$|/.*)
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
请注意,这两个的RewriteCond
的说明都是相同的。
Note that both RewriteCond
instructions are identical.
这篇关于排除来自CakePHP的应用程序根文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!