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
Php .htaccess 301重定向匹配_Php_.htaccess_Redirect - Fatal编程技术网

Php .htaccess 301重定向匹配

Php .htaccess 301重定向匹配,php,.htaccess,redirect,Php,.htaccess,Redirect,我正在尝试将特定格式的所有URL重定向到另一个URL。我已经找到了我所期望的工作,并且似乎没有太多其他的操作来完成这项工作,但是这个操作似乎在查询字符串处崩溃了 我目前的情况是: RedirectMatch 301 ^/catalogue/index\.php(.*)c=11(.*)$ http://www.domain.com/walking/ 以下是我尝试重定向的URL类型的几个示例: /catalogue/index.php?x=12&c=11&y=19 /catalog

我正在尝试将特定格式的所有URL重定向到另一个URL。我已经找到了我所期望的工作,并且似乎没有太多其他的操作来完成这项工作,但是这个操作似乎在查询字符串处崩溃了

我目前的情况是:

RedirectMatch 301 ^/catalogue/index\.php(.*)c=11(.*)$ http://www.domain.com/walking/
以下是我尝试重定向的URL类型的几个示例:

/catalogue/index.php?x=12&c=11&y=19
/catalogue/index.php?c=11&y=19
/catalogue/index.php?c=11

非常欢迎对此提供任何反馈,谢谢。

尝试将此内容写入.htaccess文件:

RewriteEngine On
RewriteCond %{QUERY_STRING} c=11
RewriteRule ^catalogue/index\.php$ http://www.domain.com/walking? [NC,L,R=301]

查询中包含“c=11”的每个对catalog/index.php的请求都将被重定向。

谢谢Christopher,成功了。但是您知道如何停止它并发送查询字符串吗?因此,它将转到www.domain.com/walking/而不是www.domain.com/walking/?c=11Nevermind!原来是你做的,我只是个傻子,最后把问号删掉了。一切都安排好了,再次感谢克里斯托弗!