Redirect test(dot) to www(dot)

All you need to do for this is simply to create the subdomain required and create two files. The code within the files are below.

Advertisements

.htaccess

RewriteEngine on

RewriteCond %{HTTP_HOST} ^test.yourdomain.co.uk$ [OR]

RewriteCond %{HTTP_HOST} ^www.yourdomain.co.uk$

RewriteRule ^/?$ “http\:\/\/yourdomain\.co.uk” [R=301,L]

 

ErrorDocument 404 /notfound.php

 

notfound.php

<?php

header(‘HTTP/1.1 301 Moved Permanently’);

header(‘Location: http://www.yourdomain.co.uk’.$_SERVER["REQUEST_URI”]);

?>

 

The following two tabs change content below.

Shane Richardson

Web Developer / Admin at HL Training Services
I have worked at various companies developing E-Commerce websites, and am keen to improve my developing skills. I also enjoy networking and maintenance. I graduated from University of the West of England and achieved a 2:2 in BSc Computing.

Latest posts by Shane Richardson (see all)