This repository has been archived on 2025-01-19. You can view files and clone it, but cannot push or open issues or pull requests.
oliverdavies.uk-old-sculpin/source/_posts/forward-one-domain-another-using-modrewrite-and-htaccess.md
Oliver Davies 85a10c545b Run prettier on all *.md files
```
prettier '{app,source}/**/**.md' --write
```
2020-03-08 17:57:45 +00:00

982 B

title date excerpt tags
Forward one domain to another using mod_rewrite and .htaccess 2012-05-23 How to use the .htaccess file to forward to a different domain.
.htaccess
code
drupal
apache
mod_rewrite

How to use the .htaccess file to forward to a different domain.

Within the mod_rewrite section of your .htaccess file, add the following lines:

RewriteCond %{HTTP_HOST} ^yoursite\.co\.uk$
RewriteRule (.*) http://yoursite.com/$1 [R=301,L]

This automatically forwards any users from http://yoursite.co.uk to http://yoursite.com. This can also be used to forward multiple domains:

RewriteCond %{HTTP_HOST} ^yoursite\.co\.uk$ [OR]
RewriteCond %{HTTP_HOST} ^yoursite\.info$ [OR]
RewriteCond %{HTTP_HOST} ^yoursite\.biz$ [OR]
RewriteCond %{HTTP_HOST} ^yoursite\.eu$
RewriteRule (.*) http://yoursite.com/$1 [R=301,L]

If any of the RewriteCond conditions apply, then the RewriteRule is executed.