Regex 使用正则表达式重定向特定URL模式

Regex 使用正则表达式重定向特定URL模式,regex,.htaccess,url,Regex,.htaccess,Url,我想重定向URL的 {integers}到{integers} 我试过: RewriteEngine On RewriteRule ^\/index\.php\?topic=(.*) https://new-URL.com/ [R=301] 但我似乎无法用我的生命来获得它。您无法以重写规则的模式与URL查询字符串(?topic=val)进行匹配。为此,您需要使用RewriteCond RewriteEngine on RewriteCond %{QUERY_STRING} ^topi

我想重定向URL的

{integers}到{integers}

我试过:

RewriteEngine On    
RewriteRule ^\/index\.php\?topic=(.*) https://new-URL.com/ [R=301]

但我似乎无法用我的生命来获得它。

您无法以重写规则的模式与URL查询字符串(
?topic=val
)进行匹配。为此,您需要使用
RewriteCond

RewriteEngine on

RewriteCond %{QUERY_STRING} ^topic=(.+)$ [NC]
RewriteRule ^index.php$ http://newurl.com/index.php?topic=%1 [L,R,NE]

在重写规则的模式中,无法与URL查询字符串(
?topic=val
)匹配。为此,您需要使用
RewriteCond

RewriteEngine on

RewriteCond %{QUERY_STRING} ^topic=(.+)$ [NC]
RewriteRule ^index.php$ http://newurl.com/index.php?topic=%1 [L,R,NE]