.htaccess 301需要htaccess重定向动态url帮助
我正试图改变方向 hhttp://www.website.net/forum/index.php?showtopic=12345 到 hhttp://www.website.ORG/forum/t12345 12345作为动态主题ID 例如,如果在主题ID之后找到任何信息,我也需要将其剥离 hhttp://www.website.net/forum/index.php?showtopic=12345&view=getlastpost 我希望清除&view=getlastpost或ID号后面可能出现的任何类似内容 我试过了 重写cond%{QUERY_STRING}^([^&]&])showtopic=([^&]+)&?(.*)$ 重写规则^index.php$[L,R=301] 但它不起作用。我在URL中得到垃圾.htaccess 301需要htaccess重定向动态url帮助,.htaccess,dynamic,redirect,url-rewriting,.htaccess,Dynamic,Redirect,Url Rewriting,我正试图改变方向 hhttp://www.website.net/forum/index.php?showtopic=12345 到 hhttp://www.website.ORG/forum/t12345 12345作为动态主题ID 例如,如果在主题ID之后找到任何信息,我也需要将其剥离 hhttp://www.website.net/forum/index.php?showtopic=12345&view=getlastpost 我希望清除&view=getlastpost或ID号后面可能出
hhttp://www.website.org/forum/index.php?showtopic=29294&view=getlastpost (when that link is clicked - the result is hhttp://www.website.net/forum/t29294?view=getlastpost/)
hhttp://www.website.org/forum/index.php?showtopic=29029 (when that link is clicked - the result is hhttp://www.website.net/forum/t29029?/).
我怎样才能清除它呢?$2意味着有两个括号内的区域,但我在您的规则中只看到一个,所以更改为$1 此外,您的URL开始/forum/因此需要将其包含在规则中 还有。如果不希望将index.php作为正则表达式特殊字符处理,则需要对其进行转义 如果您想在showtopic=1234之后删除任何内容,那么只需删除表示字符串结尾的$
RewriteRule ^forum/index\.php?showtopic=([0-9]*) http://www.website.org/forum/t$1/ [L,R=301]
对不起,它坏了。检查第一个问题我已经更新了一些东西。添加hhttp是为了逃避本网站系统对问题中url编号的限制。很抱歉