Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.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用于删除项目id的重定向规则_.htaccess_Joomla - Fatal编程技术网

.htaccess用于删除项目id的重定向规则

.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

我想重定向以下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+)
    =匹配任何数字
  • -
    =连字符
  • ([^/]*)
    =除正斜杠以外的任何字符
  • $2
    =重定向到第二个匹配组-
    ([^/]*)
  • [R=301]
    =使用HTTP 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