how to set up redirects by using .htaccess

To redirect a domain.com to www.domain.com

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

To redirect a subdomain sub.domain.com to www.newdomain.com

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

Redirecting a website in PHP

<?php
header( ‘Location: http://www.domain.com/new_page.html’ ) ;
?>

You need to add provided code in your index.php file. it will be redirected to http://www.domain.com/new_page.html.

Tagged , . Bookmark the permalink.

Leave a Reply