对于我的某个网站,我必须将重定向匹配更改为重写规则以保持模块同步,或者删除mod_alias。
我尝试了一些但是没有成功可以有人请帮助。
RewriteCond %{HTTP_HOST} ^(.*)mywebsite.com [NC]
RedirectMatch 301 ^/([0-9]{4})/([0-9]{2})/([0-9]{2})/(.*)$ http://www.mywebsite.com/$1/$2/$4
RedirectMatch 301 ^/search/page/(.*)$ http://www.mywebsite.com/?s&paged=$1
试图使用mod_rewrite但没有成功
RewriteCond %{HTTP_HOST} ^(.*)mywebsite.com [NC]
RewriteRule ^/([0-9]{4})/([0-9]{2})/([0-9]{2})/(.*)$ http://www.mywebsite.com/$1/$2/$4 [NC,L,R=301]
RewriteRule ^/search/page/(.*)$ http://www.mywebsite.com/?s&paged=$1 [NC,L,R=301]
答案 0 :(得分:1)
您可以使用以下两条规则:
RewriteCond %{HTTP_HOST} ^(www\.)?mywebsite\.com$ [NC]
RewriteRule ^(\d{4})/(\d{2})/(\d{2})/(.*)$ /$1/$2/$4 [NC,L,R=301]
RewriteCond %{HTTP_HOST} ^(www\.)?mywebsite\.com$ [NC]
RewriteRule ^search/page/(.+)$ /?s&paged=$1 [NC,L,R=301]