简体   繁体   English

在域名之前使用www时,Cakephp会重定向到/ app / webroot

[英]Cakephp redirects to /app/webroot when using www before domain name

When I enter my domain name with 'www' for example http://domain.nl everything works fine but when I use the same domain with 'www' before it, it redirects to /app/webroot which gives errors. 当我用'www'输入我的域名时,例如http://domain.nl,一切正常,但当我在它之前使用相同的域名'www'时,它会重定向到/ app / webroot,这会产生错误。 What could the problem be? 问题是什么?

I use the default cakephp .htaccess files 我使用默认的cakephp .htaccess文件

<IfModule mod_rewrite.c>
 RewriteEngine on
 RewriteRule    ^$ app/webroot/    [L]
 RewriteRule    (.*) app/webroot/$1 [L]
</IfModule>

You can Check first your rewrite mode is on or not in apache\\conf\\httpd.conf file 您可以首先检查您的重写模式是否在apache\\conf\\httpd.conf文件中

check below code in httpd.conf file 检查httpd.conf文件中的以下代码

#LoadModule rewrite_module modules/mod_rewrite.so

hash remove in this line and restart apache server hash删除此行并重启apache服务器

After then you can set 之后你可以设置

RewriteBase /YOURPATH/ 

Or 要么

RewriteBase /

in htacess 在htacess

I think you can try this 我想你可以尝试一下

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteBase /YOURPATH/
    RewriteRule    ^$    app/webroot/    [L]
    RewriteRule    (.*) app/webroot/$1    [L]

 </IfModule>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM