htaccess 301重定向问题

时间:2011-08-22 13:39:44

标签: .htaccess redirect slug

我的网站有以下网址结构:

http://domain.com/slug/1/test-test.html
http://domain.com/slug/2/test-test.html

我希望将其更改为

http://domain.com/new-1-test-test.html
http://domain.com/new-2-test-test.html

我已经尝试了

RewriteRule ^slug$ /new- [R=301,L]
RewriteRule ^/?my\slug /new [R=301,L]

但它不起作用.. 有谁知道如何使用htaccess重定向?

由于

2 个答案:

答案 0 :(得分:1)

试试这个 - RewriteRule ^slug/([0-9]+)/(.*)$ /new-$1-$2 [R=301, L]

答案 1 :(得分:0)

RewriteEngine On
RewriteRule ^slug/([0-9])/(.*)$ /new-$1-$2 [R-301,L]