.htaccess用于删除项目id的重定向规则
我想重定向以下URL: 发件人:.htaccess用于删除项目id的重定向规则,.htaccess,joomla,.htaccess,Joomla,我想重定向以下URL: 发件人: 至: 我有以下代码: RewriteCond %{QUERY_STRING} id=13 RewriteRule (.*)$ http://www.example.com/articlename [R=301,L] 在重写过程中,您需要一个querystring参数id,但在您的示例中,它实际上是URL的一部分 RewriteEngine on RewriteBase / RewriteRule (\d+)-([^/]*) $2 [R=301,L] (\d
至: 我有以下代码:
RewriteCond %{QUERY_STRING} id=13
RewriteRule (.*)$ http://www.example.com/articlename [R=301,L]
在重写过程中,您需要一个querystring参数
id
,但在您的示例中,它实际上是URL的一部分
RewriteEngine on
RewriteBase /
RewriteRule (\d+)-([^/]*) $2 [R=301,L]
=匹配任何数字(\d+)
=连字符-
=除正斜杠以外的任何字符([^/]*)
=重定向到第二个匹配组-$2
([^/]*)
=使用HTTP 301重定向(如果希望将其重写而不是重定向,请省略)[R=301]
=最后一条规则(不处理以下规则)[L]
+1用于测试链路。但是Joomla对.htaccess中的这种变化并不满意。它给出了404个错误。
input url
http://www.example.com/13-articlename
output url
http://www.example.com/articlename
debugging info
1 RewriteEngine on
2 RewriteBase /
3 RewriteRule (\d+)-([^/]*) $2 [R=301,L]
This rule was met, the new url is http://www.example.com/articlename
Test are stopped, because of the R in your RewriteRule options.
A redirect will be made with status code 301