![](/img/trans.png)
[英]How can I redirect all pages to https, using .htaccess, with exceptions?
[英]How can I write a .htaccess redirect to find all numbers?
我正在尝试找出一个正则表达式,该正则表达式将在URL中找到一些数字并在重定向到的URL中使用它们。
Redirect 301 /page.php?id=95485666 http://test.com/profile/info/id/95485666
我在想
Redirect 301 /page.php?id=([0-9]+) http://test.com/profile/info/id/$1
但它似乎不起作用
另外,如果我执行301重定向,我必须将代码保留在.htaccess文件中多长时间? Google何时会发现新链接是好的链接?
您不能与Redirect
指令中的查询字符串匹配(也不能在RedirectMatch
/ RewriteRule
匹配)。 您需要使用mod_rewrite的%{QUERY_STRING}
var:
RewriteEngine On
RewriteCond %{QUERY_STRING} (^|&)id=([0-9]+)($|&)
RewriteRule ^/?page\.php$ http://test.com/profile/info/id/%2? [L,R=301]
好吧,我猜想语法是不正确的。 尝试这个:
RewriteRule ^page.php?id=([0-9]+) http://test.com/profile/info/id/$1 [R=301,L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.