2017-08-27 140 views
1

我有一個網站,例如:example.com重定向舊網址與的.htaccess

我想用的.htaccess的URL重定向到B網址:

一個:/global/index.php?option =大約 b:/ news/group/13/

我測試&搜索很多次但沒有結果!

這是我的代碼:

RewriteEngine on 

RedirectMatch ^(.*)about(.*)$ http://example.com/news/group/13/$1 

RedirectMatch ^/global/index.php?option=about$ http://example.com/news/group/13/$1 

RedirectMatch ^/index.php?option=about$ http://example.com/news/group/13/$1 

Redirect permanent /global/index.php?option=about example.com/news/group/13/ 

回答

1

選項=約是在您的網址查詢字符串的一部分,並使用RedirectMatch爸爸,你不能測試它和重定向指令。你需要使用%{QUERY_STRING}變量

RewriteEngine on 


RewriteCond %{QUERY_STRING} ^option=about$ 
RewriteRule^/news/group/13? [L,R] 

空問號捕捉到它?在目標路徑的末尾非常重要,因爲它會丟棄來自新url的舊查詢字符串。