301 redirect everything to new website root/whole site including sub pages? Moved Permanently
.htaccess, http-status-code-301, mod-rewrite, redirect
Solution
I'd like to redirect all of my old site links from `http://artygirl.co.uk/` to my new one `http://brightmist.co.uk/`
There are several ways to achieve that, all of them should be implemented in one .htaccess file in `http://artygirl.co.uk/` root directory.
There is no need to check for the incoming domain as it must be `artygirl.co.uk`, where the .htaccess file is located.
To use any of the following options, copy-paste the corresponding directive or rule-set into one empty .htaccess file in `http://artygirl.co.uk` root directory.
The fastest one is a simple Redirect using one `mod_alias` directive:
Redirect 301 / http://brightmist.co.uk/
Any path in the incoming URL will be appended automatically to the redirected URL.
To redirect only certain paths using another `mod_alias` directive:
RedirectMatch 301 ^/(.*) http://brightmist.co.uk/$1
Although this example redirects everything, the regex `^/(.*)` can be modified to match only certain URL-path pattern.
To redirect only certain paths using `mod_rewrite` directives:
Options +FollowSymlinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) http://brightmist.co.uk/$1 [R=301,NC,QSA,L]
As in the previous option, although this rule-set redirects everything, the regex `^(.*)` can be modified to match only certain URL-path pattern.
NOTES
The same directory structure and files in `http://artygirl.co.uk/` must exist in `http://brightmist.co.uk/` for any of the previous options to work.
If the actual .htaccess file in your question works as expected, you could use it in `http://brightmist.co.uk/` root directory where the new WP is installed. Might require some modifications, though.
To move or copy a WP install, check this link Changing the site URL.
UPDATE:
From these sentences in your comment to this answer: "My domains both point at the same directory..." and "...now it creates a loop...", maybe the question is about domains pointing to the same content (Website), normally known as `parked` domains.
If that's the case, I am not sure redirecting in .htaccess the primary domain to the parked one is the correct approach just to change the domain name in the browser's address bar.
However, in theory something like this should do it using mod_rewrite directives:
Options +FollowSymlinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} artygirl\.co\.uk [NC]
RewriteRule ^(.*) http://brightmist.co.uk/$1 [R=301,NC,QSA,L]
Redirects permanently any request from `http://artygirl.co.uk` to `http://brightmist.co.uk`, appending the complete incoming path and query when present.
Since the .htaccess file is also shared, I think this rule-set should be placed at the top of the .htaccess file in the question, replacing the following lines:
RewriteEngine On
RewriteBase /
Problem
QUICK UPDATE Ok getting there Is this mod_alias? ``` RedirectMatch 301 ^/ http://brightmist.co.uk/ ``` I've added this one line of code underneath everything and it appears to work, however my other directories such as http://brightmist.co.uk/blog/2013/02/23/manchester-art-gallery-feb-2013 are telling google these pages have temporarily moved - see http://www.internetofficer.com/seo-tool/redirect-check/ Does this mean I have to go right the way though my site and add a tone of redirects? ORIGINAL QUESTION I have a new website. I'd like to redirect all of my old site links from http://artygirl.co.uk to my new one http://brightmist.co.uk/ I'm primarily a designer with years of experience using mainly in Photoshop, CSS, HTML, Wordpress, and jQuery but I don't know much about editing things like the htaccess file. And I don't want to get it wrong as it means google ranking drops etc Does anyone know of any script I can paste into the bottom of my htaccess file, I'd like it to redirect all links/pages on the site to the same place as before. For example if I type http://artygirl.co.uk/buy-art-prints-cheshire/ I want it to go to http://brightmist.co.uk/buy-art-prints-cheshire/ I'm using the same host, they've just re-pointed the domain Among other things my host has recently added the following code, I assume this is also to do with the domain mapping, also here is my whole htaccess file - ``` ErrorDocument 401 /forms/401.html ErrorDocument 403 /forms/403.html RewriteEngine On RewriteBase / #uploaded files RewriteRule ^(.*/)?files/$ index.php [L] RewriteCond %{REQUEST_URI} !.*wp-content/plugins.* RewriteRule ^(.*/)?files/(.*) wp-includes/ms-files.php?file=$2 [L] # add a trailing slash to /wp-admin RewriteCond %{REQUEST_URI} ^.*/wp-admin$ RewriteRule ^(.+)$ $1/ [R=301,L] RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule . - [L] RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-.*) $2 [L] RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L] RewriteRule . index.php [L] <IfModule mod_security.c> <Files async-upload.php> SecFilterEngine Off SecFilterScanPOST Off </Files> </IfModule> <Files 403.shtml> order allow,deny allow from all </Files> deny from 218.143.4.127 deny from 143.90.221.204 deny from 95.135.78.190 deny from 114.108.150.74 deny from 95.135.111.205 deny from 91.124.239.150 deny from 94.178.2.93 deny from 91.124.206.118 deny from 91.124.226.116 deny from 118.98.32.34 deny from 94.180.252.133 deny from 58.27.140.58 deny from 77.93.197.83 deny from 88.191.63.27 # Hotlink Protection START # RewriteEngine on RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?brightmist.co.uk [NC] RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?google.com [NC] RewriteRule \.(jpg|jpeg|png|gif)$ - [NC,F,L] # Hotlink Protection END # ```