如何进行301重定向?

时间:2015-07-07 12:56:28

标签: regex .htaccess redirect http-status-code-301

我的htaccess中有这段代码

RewriteRule ^/?watch-([a-zA-Z0-9\-]+)-tvshow-season-([0-9]+)-episode-([0-9]+)-online-free.html$ index.php?menu=episode&perma=$1&season=$2&episode=$3&lang=en [L]

旧的

RewriteRule ^/?show/([a-zA-Z0-9\-]+)/season/([0-9]+)/episode/([0-9]+)$ index.php?menu=episode&perma=$1&season=$2&episode=$3&lang=en [L]

所以我希望旧的重定向到新的 像这样

Redirect 301  /?show/([a-zA-Z0-9\-]+)/season/([0-9]+)/episode/([0-9]+)  /?watch-([a-zA-Z0-9\-]+)-tvshow-season-([0-9]+)-episode-([0-9]+)-online-free.html

1 个答案:

答案 0 :(得分:1)

Redirect指令不使用正则表达式。请改用RedirectMatch,您必须在目标网址中使用反向引用:

RedirectMatch 301 ^/show/([a-zA-Z0-9-]+)/season/([0-9]+)/episode/([0-9]+) /watch-$1-tvshow-season-$2-episode-$3-online-free.html