2016-09-14 74 views
1

实例的URL:的htaccess的RewriteCond通配符和钢带

http://example.com/guest/book3/book21.php?title.htm 
http://example.com/guest/book391/book418.php?title.htm 
http://example.com/guest/book15/book1049.php?title.htm 

这些都需要重定向到一个URL:

http://example.com/new/ 

我们需要从网址中去除一切,只需要直接重定向到URL。

我有这个,但未能:

RewriteCond %{REQUEST_URI} ^/guest/book([0-9]+)$/book([0-9]+)$.php 
RewriteRule . https://%{HTTP_HOST}/new/ [R,L] 

回答

1

你并不需要使用RewriteCond,你可以做到这一点在RewriteRule自己:到底会剥离以前

RewriteRule ^guest/book\d+/book\d+ /new/? [NC,R=301,L] 

?请求参数。