【发布时间】:2016-08-26 07:23:25
【问题描述】:
谁能帮我将旧的动态 url 格式更改为新的动态 url 格式?
确切地说,我需要将下划线 _ 更改为连字符 - 在 url 中,但使用 301 重定向 在 htaccess 中重定向,例如:
- example.com/posts/22_keyword/33_this_is_the_example_of_old_url.html
我希望它是:
- example.com/posts/22-keyword/33-this-is-the-example-of-old-url.html
我知道如何在 php 中更改它,但我需要使其适用于从旧 url 格式到新的 301 重定向 在 htaccess 中,所以我不会失去在 google 上的排名。
这是当前的 htaccess 信息:
RewriteRule ^posts/([0-9]+)([-_][^/]*)?/([0-9]+)([-_][^/]*)?/([0-9]+)([-_][^/]*)?\.html index.php?view=showad&adid=$7&cityid=$1 [QSA]
转换为:
- posts/3_keyword/6_keyword/235530_this_is_the_example_of_old_url.html
我不熟悉 mod rewrite,我想这对于了解它的人来说有点容易,因为 所要做的就是从 _ 更改为 -
【问题讨论】: