0

我正在使用 CakePHP,我刚刚将此代码添加到 app/webroot/.htaccess 以便将所有http://mywebsite.com重定向到 www.mywebsite.com

<IfModule mod_rewrite.c>
    RewriteEngine On

##########added lines 
   RewriteCond %{HTTP_HOST} !^www. [NC]
   RewriteCond %{HTTP_HOST} !^localhost [NC]
   RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
##########end of adding 


    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
</IfModule>

现在我有大问题。登录表单不再起作用。我猜这是因为它尝试将 POST 信息发送到http://mywebsite.com/login,然后在 .htaccess 中它被重定向到 www.mywebsite.com/login 但 POST 数据丢失。

我该如何解决这个问题?

在 CakePHP 中,当用户登录成功时,我使用此重定向:

$this->redirect('/posts');

**更新:我也尝试过其他重定向,但没有结果:

$this->redirect(array('controller'=>'posts', 'action' => 'index'));

谢谢。

4

0 回答 0