我要重定向
1)
https://example.com/abc/bluesnrnb-songs-abcd/
https://example.com/abc/bluesnrnb-songs-hgdf/
https://example.com/abc/bluesnrnb-songs-jhgf/
到
https://example.com/abc/blues_n_rnb-songs-abcd/
https://example.com/abc/blues_n_rnb-songs-hgdf/
https://example.com/abc/blues_n_rnb-songs-jhgf/
2)
https://songdew.com/travel/compose-asdf-efgh/222
到
https://example.com/travel/compose_asdf_efgh/222
通过 htaccess 文件。
你能帮我解决这个问题吗?
最佳答案
我不知道为什么以及你想用这个 url 做什么,但也许你可以得到 url 的第三部分,然后用你的编程语言重定向。
喜欢:
RewriteEngine On
RewriteRule ^travel/([^/]*)/?(.*)$ /index.php?action=$1 [L]
如果你使用 index.php
这会给你 compose-asdf-efgh
然后你可以做任何你想做的事情然后重定向。
一些提示:
在 seo 友好的 url 中使用 -
比使用 _
更好,
正如这个消息来源所说:http://www.ecreativeim.com/blog/2011/03/seo-basics-hyphen-or-underscore-for-seo-urls/
关于.htaccess - 重定向动态网址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40153293/