2017-04-25 85 views
0

我寫的htaccess重寫 我實際的URL是重定向URL已經在htaccess的

https://www.example.com/index.php?route=information/partnership_form 

改寫爲

https://www.example.com/for-brands/partner-with-us 

因爲我已經寫規則爲

`RewriteRule ^for-brands/partner-with-us$ https://www.example.com/index.php?route=information/partnership_form [NC,L]` 

工作正常但我想要重定向,如果一些用戶訪問direclty https://www.example.com/index.php?route=information/partnership_form

https://www.example.com/for-brands/partner-with-us

下面

是我的代碼重定向,但我已經嘗試過很多辦法形成計算器等環節仍然我找不到任何解決方案

rewriterule ^index\.php?route=information\/partnership_form(.*)$ /for-sports-brands/partner-with-us$1 [r=301,nc] 

回答

0

你不能操縱查詢字符串像那。您需要使用RewriteCond

RewriteEngine on 

RewriteCond %{QUERY_STRING} ^route=information/partnership_form [NC] 
RewriteRule ^index\.php$ /for-brands/partner-with-us? [NC,L,R] 

?重寫目標末尾的非常重要,因爲它會丟棄舊的querystrings。

+0

我試過了你的代碼,但是它的retuning error這個頁面沒有正確的重定向,如果我在'rewriteRule^index \ .php $/for-sports-brands/partner-with-我們? [NC,L,R]' –