.htaccess 301 redirect all pages on old domain to a single page on new domain

前端 未结 3 500
日久生厌
日久生厌 2020-12-07 03:07

I\'m looking to redirect each and every page on the old domain to a single page on the new domain. It should also redirect both the www and

3条回答
  •  执念已碎
    2020-12-07 03:28

    You can use RedirectMatch in the old.com vhost

    RedirectMatch permanent .* http://www.new.com/
    

    Redirect appends the trailing portion of the matched URI to the redirection URI but with RedirectMatch it's up to you to choose the parts (if any) that you want to transfer using parentheses and $number references.

    If the old and new domains must be aliases for the same document root on disk then you'll probably have to use mod_rewrite

    RewriteEngine on
    RewriteCond %{HTTP_HOST} old\.com$
    RewriteRule .* http://www.new.com/ [L,R=301]
    

提交回复
热议问题