[英].htaccess: Redirect all pages to a new domain, except certain pages
[英].htaccess: Redirect all pages to root of new domain, except in some cases
我可以使用它來將所有頁面重定向到新域的根目錄:
Options +FollowSymLinks -MultiViews
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?old\.com$ [NC]
RewriteRule ^ http://www.new.com/ [R=301,L]
但是,我想添加一些更明確的重定向規則,例如:
RedirectMatch 301 /something/(\d+)(\D*) https://www.newsite.net/foobar/$1
但是,如果我也將代碼從上面放入,則后一個規則將不再起作用。將RedirectMatch
規則放在其他代碼的上方還是下方也沒關系。
僅使用RewriteRule
並在通用類之前保留特定的重定向:
Options +FollowSymLinks -MultiViews
RewriteEngine on
RewriteRule ^something/(\d+)(\D*) https://www.newsite.net/foobar/$1 [L,NC,R=301]
RewriteCond %{HTTP_HOST} ^(www\.)?old\.com$ [NC]
RewriteRule ^ http://www.new.com/ [R=301,L]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.