域被mod_rewrite重定向到suddirectory但是cakePHP正在搞乱网址

时间:2011-05-24 22:08:21

标签: .htaccess cakephp mod-rewrite

我目前将主域名从根目录重定向到子目录。因此,每当我使用cakePHP来编写网址或获取当前网址时,它都会显示子目录。

例如: 如果我在主页(http://example.com)然后使用cake的$this->url它将返回/ mysubdirectory /

这是我在我的根目录中使用的.htaccess文件(当然经过修改以符合我的需要),该文件重定向到子目录。

# Hostmonster.com
# .htaccess main domain to subdirectory redirect
# Copy and paste the following code into the .htaccess file
# in the public_html folder of your hosting account
# make the changes to the file according to the instructions.
# Do not change this line.
RewriteEngine on
# Change yourdomain.com to be your main domain.
RewriteCond %{HTTP_HOST} ^(www.)?yourmaindomain.com$
# Change 'subdirectory' to be the directory you will use for your main domain.
RewriteCond %{REQUEST_URI} !^/subdirectory/
# Don't change this line.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Change 'subdirectory' to be the directory you will use for your main domain.
RewriteRule ^(.*)$ /subdirectory/$1
# Change yourdomain.com to be your main domain again.
# Change 'subdirectory' to be the directory you will use for your main domain
# followed by / then the main file for your site, index.php, index.html, etc.
RewriteCond %{HTTP_HOST} ^(www.)?yourmaindomain.com$
RewriteRule ^(/)?$ subdirectory/index.php [L]

我觉得我需要修改cakePHP应用程序中的.htaccess文件以忽略子目录,但我不确定如何。

1 个答案:

答案 0 :(得分:0)

你添加了

RewriteBase /subdirectory/

在您的/ app和/ cake文件夹所在的目录中的.htaccess中?