【发布时间】:2011-10-01 21:48:18
【问题描述】:
我有点卡住 RewriteRule 301,从旧新闻 ID 更改为新新闻 ID
这是我尝试过的:
RewriteRule ^/news/0(.*)$ /news/$1 [L,R=301]
假设新闻 URL 看起来像他的:
http://www.mydomain.com/news/01/title-of-the-new
http://www.mydomain.com/news/09/title-of-the-new
http://www.mydomain.com/news/012/title-of-the-new
http://www.mydomain.com/news/032/title-of-the-new
我想改成:
http://www.mydomain.com/news/1/title-of-the-new
http://www.mydomain.com/news/9/title-of-the-new
http://www.mydomain.com/news/12/title-of-the-new
http://www.mydomain.com/news/32/title-of-the-new
【问题讨论】:
-
看起来应该可以,你得到了什么样的结果?
-
Ross,它不会从 01 重定向到 1(示例)。
-
这可能是由于另一个规则 - 我刚刚测试了这个,
http://localhost/news/01/hello重定向到http://localhost/news/1/hello。 -
我设法修复了它。将
RewriteRule ^/news/0(.*)$ /news/$1 [L,R=301]替换为RewriteRule ^news/0(.*)$ /news/$1 [L,R=301] -
很高兴您修复了它,请将其发布为答案 :)
标签: apache .htaccess url mod-rewrite seo