1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to fix non www to www redirect problem?

Discussion in 'Search Engine Optimization' started by bushib, Apr 5, 2007.

  1. #1
    Hi there,

    I want to know that how to fix non www to www redirect problem.

    Is there any simply method of doing fixing this problem without any coding.

    Additionally, will I have to fix all the pages of my website?

    Best Regards
    bushib
     
    bushib, Apr 5, 2007 IP
  2. ninjashoes

    ninjashoes Well-Known Member

    Messages:
    1,401
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    138
    #2
    whats your htaccess look like?
     
    ninjashoes, Apr 5, 2007 IP
  3. Pammer

    Pammer Notable Member

    Messages:
    3,417
    Likes Received:
    397
    Best Answers:
    0
    Trophy Points:
    260
    #3
    RewriteEngine On
    RewriteEngine onRewriteCond %{HTTP_HOST} ^yoursitename\.com
    RewriteRule (.*) http://www.yoursitename.com/$1 [R=301,L]
    Code (markup):
    Put this one, in notepad then save as ".htaccess" and then upload in public_html

    sure that, put your site name instead of "yoursitename". Hope it works
     
    Pammer, Apr 5, 2007 IP
    BigBadWolf likes this.
  4. BigBadWolf

    BigBadWolf Well-Known Member

    Messages:
    1,727
    Likes Received:
    67
    Best Answers:
    0
    Trophy Points:
    140
    #4
    BigBadWolf, Apr 5, 2007 IP
  5. trichnosis

    trichnosis Prominent Member

    Messages:
    13,785
    Likes Received:
    333
    Best Answers:
    0
    Trophy Points:
    300
    #5
    you can not solve that without coding . the best way is inserting

    RewriteEngine On

    RewriteCond %{HTTP_HOST} ^seo4fun\.com [NC]
    RewriteRule ^(.*)$ http://www.seo4fun.com/$1 [R=301]

    to your .htaccess file :)
     
    trichnosis, Apr 5, 2007 IP
    dynamicseo likes this.
  6. bushib

    bushib Banned

    Messages:
    1,096
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Hi there,

    I want to know that is the following code is enough or there is something more to be written in the file

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

    Secondly please look at the following code is it correct?

    Let's say my domain name is abc.com and I write code as following


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

    Please tell me is the syntax of the above code is correct and additionally should I change every page of my site with the same syntax?

    Regards

    Regards
    bushib
     
    bushib, Apr 6, 2007 IP
  7. lukazs

    lukazs Well-Known Member

    Messages:
    583
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    125
    #7
    Yeah, it looks good. This should work
     
    lukazs, Apr 6, 2007 IP
  8. Pammer

    Pammer Notable Member

    Messages:
    3,417
    Likes Received:
    397
    Best Answers:
    0
    Trophy Points:
    260
    #8
    Pammer, Apr 6, 2007 IP
  9. seo_expert

    seo_expert Well-Known Member

    Messages:
    475
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    123
    #9
    You can also use Google’s webmaster console to tell Google your preferred way of using the domain: www or without www

    You can also go for Canonical Hostname Redirect (non-www to www) in your .htaccess file as most of the members have sugegsted with code for it to work.

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^domain\.com
    RewriteRule (.*) http://www.domain.com/$1 [R=301,L]
     
    seo_expert, Apr 6, 2007 IP
    bushib likes this.
  10. Linkmeup

    Linkmeup Peon

    Messages:
    197
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Modifying htaccess is the easiest way of accomplish your goal. It's a pretty simple change and easy to roll back if you need to for some reason.
     
    Linkmeup, Apr 6, 2007 IP
  11. Shashi01

    Shashi01 Peon

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    what if you cant access the htaccess file??? I heard there is one code (for asp pages) that you have to put to get the same work done. Does anyone knows about it??

    Thanks
    Shashi Jones
     
    Shashi01, Apr 6, 2007 IP
  12. kh7

    kh7 Peon

    Messages:
    2,715
    Likes Received:
    109
    Best Answers:
    0
    Trophy Points:
    0
    #12
    I personally go by the google webmaster-tool method mentioned by 'seo-expert'.
     
    kh7, Apr 6, 2007 IP
  13. Shashi01

    Shashi01 Peon

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #13
    I have already done that in the google's webmaster console. But would like the visitors to be transferred to the www mode if they enter the domain name without www.

    How is that possible??? may be some asp code that i need to fit in the header of the pages??

    Also how to get rid from the www.mydomain.co.uk/index.asp wherein i dont want them and want to keep the non index version. I dont have any page that links to the index.asp version.

    Please guide.

    Thanks
     
    Shashi01, Apr 6, 2007 IP
  14. dynamicseo

    dynamicseo Banned

    Messages:
    416
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    0
    #14
    Hey, i recently applied this code into my site and its woking properly. Check by typing this into your browser = vivavibrators.co.uk

    -dynamicseo
     
    dynamicseo, Apr 6, 2007 IP
  15. Shashi01

    Shashi01 Peon

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #15
    i think that this code needs to be implemented in the htaccess file. Would it be possible for you to comment on it dynamicseo ???

    TA
     
    Shashi01, Apr 6, 2007 IP
  16. bushib

    bushib Banned

    Messages:
    1,096
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #16
    Hi there,

    My actual website is placed in the following place

    /public_html/test/

    I uploaded the following .httaccess file in the above location.

    RewriteEngine On
    RewriteEngine onRewriteCond %{HTTP_HOST} ^test\.info
    RewriteRule (.*) http://www.test.info/$1 [R=301,L]

    And I check the my home page in the browser like this

    http://test.info/ (without www)

    I can access it successfully even after uploading the .httaccess file in the

    following two places

    /public_html
    /public_html/test/

    Please note I can host 5 domains in the same account so "test" folder is for the domain in question.

    Secondly, I am using the name "test" just for example.

    Now anyone please tell me how to resolve this problem?

    I will be really thankful to anyone who can assist me in this matter.

    Best Regards
    bushib
     
    bushib, Apr 6, 2007 IP
  17. rodney88

    rodney88 Guest

    Messages:
    480
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    0
    #17
    It's missing a line break. Every command in an .htaccess file must be on it's own line:
    Options +FollowSymLinks
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^test\.info$
    RewriteRule ^(.*)$ http://www.test.info/$1 [R=301,L]
    Code (markup):
     
    rodney88, Apr 6, 2007 IP
  18. Tigerboy

    Tigerboy Well-Known Member

    Messages:
    49
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    111
    #18
    Hy,

    I want to redirect my non www webiste to www. The problem is that the server where my domain is hosted doesn't support .htaccess file. What should i do? I read that i can use a php redirection. But where to put the php redirection code? How can i redirect my entire site (including subpages)?
    Thanks in advance!
     
    Tigerboy, Oct 7, 2009 IP
  19. EYAN

    EYAN Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #19
    Thanks so much Pammer for this info :)
     
    EYAN, Dec 17, 2009 IP
  20. Frost813

    Frost813 Peon

    Messages:
    261
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #20
    ASP

    <%@ Language=VBScript %>
    <%
    Response.Status="301 Moved Permanently"
    Response.AddHeader "Location", "http://www.new-url.com/"
    %>


    PHP

    <?
    header( "HTTP/1.1 301 Moved Permanently" );
    header( "Status: 301 Moved Permanently" );
    header( "Location: http://www.new-url.com/" );
    exit(0); // This is Optional but suggested, to avoid any accidental output
    ?>


    -----------------------------------------------------------------------

    Here is every other method for redirect that I've collected. I hope that this answers any questions about redirects.


    Meta Tag

    <meta http-equiv="refresh" content="0;url=http://example.com/" />



    .htaccess

    Redirect 301 /old/old.html http://www.you.com/new.html



    Mod_Rewrite

    RewriteEngine On
    rewritecond %{http_host} ^yoursite.com
    rewriteRule ^(.*) http://www.yoursite.com/$1 [R=301,L]



    301 Redirect Using IIS

    In internet services manager, right click on the file or folder you wish to redirect.
    Select the radio titled "a redirection to a URL".
    Enter the page that the page will be redirected to.
    Check "The exact url entered above" and the "A permanent redirection for this resource".
    Click on 'Apply'.



    ColdFusion

    <cfheader statuscode="301" statustext="Moved permanently">
    <cfheader name="Location" value="http://www.new-url.com/">



    ASP.Net

    <script runat="server">
    private void Page_Load(object sender, System.EventArgs e)
    {
    Response.Status = "301 Moved Permanently";
    Response.AddHeader("Location","http://www.new-url.com/");
    }
    </script>



    JAVA (Not Recommended)

    <%
    response.setStatus(301);
    response.setHeader( "Location", "http://www.new-url.com/" );
    response.setHeader( "Connection", "close" );
    %>


    PERL

    $q = new CGI;
    print $q->redirect(" http://www.new-url.com/ ");
     
    Frost813, Dec 17, 2009 IP