“Adsterra”/ “AdsKeeper”/
Welcome to Our Community
Wanting to join the rest of our members? Feel free to sign up today.

Queries about website domain name URL redirection

Discussion in 'Search Engine Optimisation' started by kpkarthik, Jun 16, 2014.

  1. kpkarthik

    kpkarthik Affiliate affiliate

    50
    0
    0
    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.
     
  2. Voluum
  3. NicholasK

    NicholasK Affiliate affiliate

    14
    0
    0
    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
     
  4. I'm H

    I'm H Affiliate affiliate

    67
    45
    0
    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
     
    4 people like this.
  5. ketul

    ketul Affiliate affiliate

    100
    2
    0
    I agree with adam. Same answer.
     
MI