简体   繁体   中英

Cakephp redirection problem

I have a problem of too many redirection in one cakephp site.

Here is the site: http://pexinxas24.com/

This domain is pointed to root of the site and not to app folder.

Here is the code which is placed in htaccess of the root folder.

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

Here is the code which is places in the htaccess of the app folder.

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

I am not getting any typs of PHP or cakephp errors.

This site always redirect to the root of the site. Whole code was working properly on old server. I have just changed the server and getting this error.

Looks like your are using Amazon-EC2 right? ;)

Well, probably you aren't redirected for the next reasons:

  1. mod_rewrite it isn't enabled : Look inside of your httpd.conf, you should have the next line uncommented:

    LoadModule rewrite_module modules/mod_rewrite.so

  2. You haven't enabled override in htaccess : Look inside of your http.conf for the
    directive "Directory", inside you should have something like this:

    \n    <Directory "/var/www/html"> \n       Options Indexes FollowSymLinks \n       AllowOverride All \n       Order allow,deny \n       Allow from all \n    </Directory> \n

    The most important line of the previous code is AllowOverride All , on amazon instances is set to AllowOverride none by default, so you should change it to All , after that you must restart your apache server to reflect changes.

Hope it helps.

This is an old thread. Probably if you understand about apache2 Ismael's answer is quite enough, but if you're a newbe in this subject as I am, might be useful saying that in apache2 nowadays you should "replace" the part one where he says

mod_rewrite it isn't enabled: Look inside of your httpd.conf, you should have the next line uncommented: LoadModule rewrite_module modules/mod_rewrite.so

for copying rewrite.load from mods-available to mods-enabled :

cp /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/rewrite.load

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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