我不知道如何重定向我的symfony应用程序: http://www.mysymfonyapp.com 至: http://mysymfonyapp.com
这是我的.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'它会重定向循环。我试过要谷歌,但我没找到任何东西。
答案 0 :(得分: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>
答案 1 :(得分: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>