Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess 重定向一个";php?模块";指向具有重写规则的新URL的URL_.htaccess_Mod Rewrite_Redirect - Fatal编程技术网

.htaccess 重定向一个";php?模块";指向具有重写规则的新URL的URL

.htaccess 重定向一个";php?模块";指向具有重写规则的新URL的URL,.htaccess,mod-rewrite,redirect,.htaccess,Mod Rewrite,Redirect,我想用以下路径重定向旧URL: index.php?module=TrackBack&id=58,2814 到另一个像这样的永久链接: new-link/ 重定向和重定向匹配无效。我知道我必须使用重写规则,但不知道如何使用。我试过这个: RewriteRule ^index.php?module=TrackBack\&id=58,2814$ /new-link/ 但它不起作用。我该怎么办 谢谢。要匹配查询字符串,您需要一个RewriteCond%{query\u strin

我想用以下路径重定向旧URL:

index.php?module=TrackBack&id=58,2814
到另一个像这样的永久链接:

new-link/
重定向和重定向匹配无效。我知道我必须使用重写规则,但不知道如何使用。我试过这个:

RewriteRule ^index.php?module=TrackBack\&id=58,2814$ /new-link/
但它不起作用。我该怎么办


谢谢。

要匹配查询字符串,您需要一个
RewriteCond%{query\u string}

使用此规则:

RewriteCond %{QUERY_STRING} ^module=TrackBack\&id=58,2814$ [NC]
RewriteRule ^(index\.php)?$ /new-link/? [R=301,L,NC]

感谢您的帮助,anubhava,但通过您的重写,这是我得到的url:mysite.com/var/www/new url/?module=TrackBack&id=582814它工作得非常好。非常感谢阿努巴瓦;-)很高兴知道,您可以点击我答案左上角的勾号,将答案标记为已接受。完成!顺便说一句,我不能更新你的答案,因为系统不允许我,直到我的声誉达到15或更高:-Pbtw我已经更新了你的问题,因为它能很好地解释问题,作为一个新用户。