Root domain redirect from Subfolder

0
131

Redirect requests with .htaccess

Redirect “ALL” requests to a domain to a subdirectory

You can redirect all requests to a subdirectory by adding an .htaccess file to the root of your domain’s directory:

  1. Visit the FTP page for instructions on how to upload.
  2. Once connected, upload (or create) a text file named .htaccess (with no extension).
  3. Make sure it’s uploaded to your domain’s directory such as example.com.
  4. Add the following content to this .htaccess file:

Redirecting to a different domain

So the example below is redirecting all URLs from olddomain.com to newdomain.com, this is also the 301 redirect to use when using Googles Change of Address tool in Search Console.

RewriteEngine On
RewriteCond %{HTTP_HOST} ^olddomain.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.olddomain.com [NC]
RewriteRule ^(.*)$ http://newdomain.com/$1 [L,R=301,NC]

The above will use the non-www as preference.