Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.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
Apache .htaccess重定向的重写规则_Apache_.htaccess_Mod Rewrite_Http Status Code 301 - Fatal编程技术网

Apache .htaccess重定向的重写规则

Apache .htaccess重定向的重写规则,apache,.htaccess,mod-rewrite,http-status-code-301,Apache,.htaccess,Mod Rewrite,Http Status Code 301,我已经为此奋斗了一段时间,但似乎无法让它发挥作用。我的旧系统使用了很多查询字符串来呈现页面,但它们不再是必需的。我的网址如下: 旧URL:www.example.com/links.php?section=5&catid=52 新网址:www.example.com/mhfs/links 名称链接是巧合,不一定来自旧页面名称。我需要检查哪个部分和catid存在,并将它们重定向到相应的页面。我尝试了以下方法,但这似乎没有任何作用。我做错了什么 RewriteCond %{REQUEST_URI

我已经为此奋斗了一段时间,但似乎无法让它发挥作用。我的旧系统使用了很多查询字符串来呈现页面,但它们不再是必需的。我的网址如下:

  • 旧URL:www.example.com/links.php?section=5&catid=52
  • 新网址:www.example.com/mhfs/links
名称链接是巧合,不一定来自旧页面名称。我需要检查哪个部分和catid存在,并将它们重定向到相应的页面。我尝试了以下方法,但这似乎没有任何作用。我做错了什么

RewriteCond %{REQUEST_URI} ^links.php$
RewriteCond %{QUERY_STRING} ^section=5$
RewriteCond %{QUERY_STRING} ^catid=52$
RewriteRule ^(.*)$ /mhfs/links? [R=301]

任何帮助都将不胜感激。

您必须打开重写引擎才能工作。 您可能不想在替换项上使用regex start符号:

重新启动发动机

重写条件


重写规则…

这属于servfault,而不是stackoverflow。我没有移动它的军衔,但你应该自己动手。对不起。。我知道我会忘记添加一些细节。我在这个文件上运行了很多其他的规则,所以我启动了重写引擎,但似乎当我使用多个变量时,我所做的一切都不起作用。