Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess 域被mod_rewrite重定向到suddirectory,但cakePHP弄乱了URL_.htaccess_Cakephp_Mod Rewrite - Fatal编程技术网

.htaccess 域被mod_rewrite重定向到suddirectory,但cakePHP弄乱了URL

.htaccess 域被mod_rewrite重定向到suddirectory,但cakePHP弄乱了URL,.htaccess,cakephp,mod-rewrite,.htaccess,Cakephp,Mod Rewrite,我目前将我的主域从根目录重定向到子目录。因此,每次我使用cakePHP编写URL或获取当前URL时,它都会显示子目录 # 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 c

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

# 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]
例如: 如果我在主页上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文件以忽略子目录,但我不确定如何添加。

您添加了吗

RewriteBase /subdirectory/

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

谢谢您的回复。。。我只是尝试了一下,但没有成功。我会从一个默认值开始。htaccess和om下一步更改重写基础,如上图所示。我认为没有必要改变其他地方的道路