如何使用htaccess将文件夹名称重定向为url param?

时间:2016-03-31 00:29:21

标签: .htaccess

我需要301将.htaccess从具有文件夹结构的旧站点重定向到使用结束文件夹名称作为url参数的新页面。

像这样:

http://example.com/artists/artist-name

http://example.com/search-works.php?searchArtist=artist-name

1 个答案:

答案 0 :(得分:1)

两个选项:

RewriteRule ^artists/artist-name$ /search-works.php?searchArtist=artist-name [R=301,NC,L]

RewriteRule ^artists/(.*)$ /search-works.php?searchArtist=$1 [R=301,NC,L]