将特定URL重写到不同的目录

时间:2012-04-20 18:27:10

标签: .htaccess mod-rewrite url-rewriting rewrite

我试图重定向这个,

example.com/ slide?page = 4 to example.com/slide/issue43?page=4

但它无法影响其他网址,例如:example.com/slide/issue57?page=4

我真的卡住了,这些正则表达式太奇怪了。这是我提出的重写,

This is not working    
RewriteRule ^slide?page(.*)$ http://example.com/slide/issue43?page=$1 [L,R=301]

我需要专门定位'幻灯片?page = X '并将其重定向或指向' slide / issue43?page = X '

1 个答案:

答案 0 :(得分:1)

这应该适合你:

RewriteCond %{REQUEST_URI} ^/slide$
RewriteCond %{QUERY_STRING} ^page=(.*)$
RewriteRule ^(.*) /slide/issue57?page=%1 [R=301,L]