.htaccess htaccess重写第二个通配符和条带
示例URL:.htaccess htaccess重写第二个通配符和条带,.htaccess,redirect,url-rewriting,.htaccess,Redirect,Url Rewriting,示例URL: 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中的所有内容,直接重定向到URL 我有一个缺点,但失败
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中的所有内容,直接重定向到URL
我有一个缺点,但失败了:
RewriteCond %{REQUEST_URI} ^/guest/book([0-9]+)$/book([0-9]+)$.php
RewriteRule . https://%{HTTP_HOST}/new/ [R,L]
您不需要使用
RewriteCond
,因为您可以在RewriteRule
本身中执行此操作:
RewriteRule ^guest/book\d+/book\d+ /new/? [NC,R=301,L]
?
最后将去掉前面的查询字符串