我想在我的网站上进行重定向。
旧网址如下:
http://www.example.com/Prem_Ratan_Dhan_Payo/Prem_Leela.html
现在我们必须将其重定向到
http://example.com/songs/prem-leela/
总的来说,我必须
请帮帮我。
答案 0 :(得分:1)
这应该让你开始:
RewriteEngine On
# Replace underscores with hyphens in all requests ending in .html.
# The rule replaces one char at a time and is repeated until no matches are found.
RewriteCond "%{QUERY_STRING}" "\.html$" [NC]
RewriteRule ^([^_]*)_(.*) $1-$2 [N]
# Capture the file name without extension inside braces
# Use a lower-case mapping on the file name.
# Destination is /songs/filename
RewriteMap lc int:tolower
RewriteRule ^.*/(.*)\.html$ /songs/${lc:$1} [NC, R=301]