The Most Active and Friendliest
Affiliate Marketing Community Online!

“AdsEmpire”/  Direct Affiliate

Queries about website domain name URL redirection

kpkarthik

New Member
affiliate
Some website has been automatically redirected to that home page while entering the domain name without WWW format.For example if i entering the website name amazon(.)com means,then it has automatically redirected to home page with WWW.
I want to know about the tricks regarding that URL redirection.
 
You have to include this code in .htaccess file(a hidden file in your hosting root). Please don't use this method if you have site in WordPress, You have to put your required URL in General settings of Your WP-Admin
 
PHP:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^domain\.com
RewriteRule (.*) http://domain.com/$1 [R=301,L]


To redirect the non-www to the www version you will need to use :

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

As mentioned above some Scripts like Wordpress automatically have this ability so there is no need to add any code above.

Also you have to remember if your site has a dedicated IP and you can access your website by typing the IP address into your browser then you will need to also redirect the IP to the domain which can be done using the following code

Code:
# IP TO DOMAIN REDIRECT
RewriteCond %{HTTP_HOST} ^214\.142\.81\.140$
RewriteRule ^(.*)$ https://www.yourdomain.co.uk/$1 [L,R=301]

Obviously replacing the IP address show above with your dedicated IP and your domain name
 
banners
Back