: Redirect everything from old domain to new domain I need to (permanent) redirect all of the following: www.domain.com www.domain.com/folder sub.domain.com sub.domain.com/folder Basically all URLS that
I need to (permanent) redirect all of the following:
domain.com www.domain.com/folder
sub.domain.com
sub.domain.com/folder
Basically all URLS that are reachable without being intended to: newdomain.com, I want to do this within Apache and using the mod_rewrite module via the htaccess file.
More posts by @Gonzalez347
4 Comments
Sorted by latest first Latest Oldest Best
Use a 301 redirect in your .htaccess file at the old domain:
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) www.newdomain.com/ [R=301,L]
Put this in your .htaccess:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.newdomain.com [NC]
RewriteRule ^(.*)$ www.newdomain.com%{REQUEST_URI} [R=301,L]
Source
Note that this .htaccess should of course apply to the old domain. Usually in situations like this, the old domain and the new domain point to the same server though, and so get the same .htaccess.
It would be better to redirect (forward) your domain at your registrar and forward the old domain which includes all sub domains to the new domain. This way your server is not handling all the requests which takes up resources.
To redirect all files on your domain use this in your .htaccess file if you are on a unix web server:
RedirectMatch 301 ^/(.*)$ www.newdomain.com/
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.