2015-04-08 16 views
0

使用symfony爲我的網站,我有一個從我的https://www.exemple.com/https://www.exemple.com/ 302重定向,谷歌不想302重定向...這是重寫部分的最後一個條件.htaccess是這樣做的。。symfony的htaccess使302重定向

<IfModule mod_rewrite.c> 
    RewriteEngine On 

    RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$ 
    RewriteRule ^(.*) - [E=BASE:%1] 

    RewriteCond %{ENV:REDIRECT_STATUS} ^$ 
    RewriteRule ^app\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L] 

    # If the requested filename exists, simply serve it. 
    # We only want to let Apache serve files and not directories. 
    RewriteCond %{REQUEST_FILENAME} -f 
    RewriteRule .? - [L] 

    # Rewrite all other queries to the front controller. 
    RewriteRule .? %{ENV:BASE}/app.php [L] 
</IfModule> 

我試圖把代替:

RewriteRule .? %{ENV:BASE}/app.php [R=301,L] 

但在這種情況下,我有一個301重定向,但我的網站是不可達。有任何想法嗎 ?

+0

你有apache模塊'mod_rewrite'嗎?你所描述的是沒有啓用時的行爲...... – Matteo

+0

嗨@Matteo並感謝您的幫助。是mod_rewrite似乎已啓用。 – user3417911

回答

0

查找解決方案,

這不是原因中的.htaccess。我是301/302重定向的新手,不知道你可以在控制器中使用它。所以我添加了一個」 301" 在重定向結束時,我做的控制器,這樣的:

return $this->redirect($this->generateUrl('sdzbikind_acceuil'), 301); 

希望它可以幫助別人......我剛纔問我是否應該做301重定向在我所有的symfony項目重定向!?