我正在使用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'));
感谢。