![](/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.