[英]Permanent redirect of page dependent on parameters
我想重新調配www.mysite.com/abc/mypage.php?id=123到www.mysite.com/newpage.htm
我已經在我的.htaccess文件中嘗試過此操作,但是它不起作用。 (我剛得到一個404)
RedirectPermanent /abc/mypage\.php\?id=123 /newpage.htm
正確的語法是什么?
不,您無法使用Redirect
指令匹配QUERY_STRING。 您可以改用mod_rewrite
:
RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+abc/mypage\.php\?id=123[&s] [NC]
RewriteRule ^ /newpage.htm? [R=302,L]
嘗試這個:
# do this once per htaccess
RewriteEngine on
RewriteCond %{QUERY_STRING} ^id=123$
# to redirect permanently
RewriteRule ^/?abc/mypage\.php$ /newpage.htm [R=301,L]
請記住, [R=302]
標志用於臨時重定向。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.