2013-07-11 69 views
0

我不知道怎麼我的symfony應用程序從重定向: http://www.mysymfonyapp.com 到: http://mysymfonyapp.comSymfony的2重定向到URL加www

這裏是我的.htaccess:

<IfModule mod_rewrite.c> 
RewriteEngine On 

RewriteCond %{HTTP_HOST} ^www\. 
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [R=301,L] 

#<IfModule mod_vhost_alias.c> 
# RewriteBase/
#</IfModule> 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteBase /mysymfonyapp.com/web/ 
RewriteRule ^(.*)$ index.php [QSA,L] 

如果我輸入的應用程序沒有'www',它可以工作,但是'www'它有重定向循環。我試過要求谷歌,但我沒有找到任何東西。

回答

1

好的,我想通了,併爲其他人回答。

<IfModule mod_rewrite.c> 
    RewriteEngine On 

    RewriteCond %{HTTP_HOST} ^www\.mysymfonyapp\.com$ [NC] 
    RewriteRule (.*) http://mysymfonyapp.com/$1 [R=301,L] 

    #<IfModule mod_vhost_alias.c> 
    # RewriteBase/
    #</IfModule> 

    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteBase /mysymfonyapp.com/web/ 
    RewriteRule ^(.*)$ index.php [QSA,L] 
</IfModule> 
0
<IfModule mod_rewrite.c> 
    RewriteEngine On 

    RewriteCond %{HTTP_HOST} ^www\.mysymfonyapp\.com$ [NC] 
    RewriteRule (.*) http://mysymfonyapp.com/$1 [R=301,L] 

    RewriteCond %{REQUEST_FILENAME} !-f 
    #RewriteBase /mysymfonyapp.com/web/ (you don't need declare RewriteBase if you have this code in mysymfonyapp/web/.htaccess) 
    RewriteRule ^(.*)$ app.php [QSA,L] #Remember to redirect app.php 
</IfModule>