2 ways to create a 301 Redirect

hcse26

New Member
Messages
94
Reaction score
0
Points
0
Redirecting with PHP

PHP:
<?
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://www.new-url.com" );
?>

Copy the source code and edit "http://www.new-url.com" with your own url and save it as a .php file

301 Redirect with .htaccess

Create a .htaccess file with the below code, it will ensure that all requests coming in to domain.com will get redirected to www.domain.com
The .htaccess file needs to be placed in the root directory of your old website (i.e the same directory where your index file is placed)

PHP:
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^domain.com [nc]
rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]

Please REPLACE domain.com and www.newdomain.com with your actual domain name.

Live demo[my site]: http://www.craigafer14.co.uk
Notice that you got redirected to http://.craigafer14.co.uk

Hope these helped and please rep me if they did :biggrin:
 

Parsa44

New Member
Messages
232
Reaction score
0
Points
0
Thanks i think it will come in rather handy for me XD, (if i dont get my DRK from my host)
 
Top