[英]htaccess 301 permanent redirect using query string
I'm trying to do a 301 with a query string.我正在尝试使用查询字符串执行 301。
I want to redirect我想重定向
www.mydomain.com/page1.php?id=12
To到
www.mydomain.com/page2.php?id=12
I've already tried this in .htaccess:我已经在 .htaccess 中尝试过这个:
RewriteEngine on
RewriteCond %{QUERY_STRING} ^page_id=([0-9]+)$
RewriteRule ^page2.php?page_id=%1 [R=301,L]
You may use this redirect rule:您可以使用此重定向规则:
RewriteEngine on
RewriteCond %{QUERY_STRING} ^id=\d+$
RewriteRule ^page1\.php$ /page2.php [R=301,L,NC]
Query string will be automatically copied over to new URL.查询字符串将自动复制到新的 URL。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.