Mobile app version of vmapp.org
Login or Join
Gonzalez347

: 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

@Gonzalez347

Posted in: #301Redirect #Apache #Htaccess #Redirects

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.

10.04% popularity Vote Up Vote Down


Login to follow query

More posts by @Gonzalez347

4 Comments

Sorted by latest first Latest Oldest Best

 

@Sent6035632

Use a 301 redirect in your .htaccess file at the old domain:

Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) www.newdomain.com/ [R=301,L]

10% popularity Vote Up Vote Down


 

@Ann8826881

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.

10% popularity Vote Up Vote Down


 

@Annie201

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.

10% popularity Vote Up Vote Down


 

@Shelley277

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/

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme