我正在将旧的动态URL重定向到新的URL,如下所示:
来自:
http://example.com/movie/movie-name
至:
http://example.com/movie_id-movie_name-example.html
电影id和电影名称是可变的,这是我以前的htaccess
RewriteRule ^/?movie/([a-z0-9'-]+)'/?$ index.php?menu=watchmovie&perma=$1&lang=en [L]
这是我的新htaccess
RewriteRule ^([0-9]+)-([a-z0-9'-]+)-example'.html$ index.php?menu=watchmovie&perma=$2&lang=en&id=$1 [L]
在正则表达式中添加下划线,假设url为:
http://yoursite.com/978632-the_hunter.html
你需要一些类似的东西:
RewriteRule ^([0-9]+)-([a-z0-9'-_]+)-example'.html$ index.php?menu=watchmovie&perma=$2&lang=en&id=$1 [L]