Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

301 Redirect

Options
  • 25-12-2008 4:59pm
    #1
    Closed Accounts Posts: 112 ✭✭


    Hi I have a site hosted on a shared windows hosting package and I wanted to use a 301 redirect from the non www. version to the www. version for better SEO. I have tried using mod rewrite but from more research it seems this will only work on Apache servers, am I right with this? I also contacted the support for my hosting which wasn't very pleasant, I was told including mod rewrite in my .htaccess should work but it doesn't seem to. Can anyone see where I am going wrong, the code I have tried in my .htaccess has all been from tutorials online.

    Thanks, and Merry Xmas:)


Comments

  • Registered Users Posts: 706 ✭✭✭DJB




  • Closed Accounts Posts: 1,200 ✭✭✭louie


    301 using htaccess
    [php]
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^\.htaccess$ - [F]
    # redirect all other domains to domain.ie
    RewriteCond %{HTTP_HOST} !^www\.domain\.ie
    RewriteRule ^(.*)$ http://www.domain.ie/$1 [R=301,L,NC]
    #redirect index.php or htm to /
    RewriteCond %{THE_REQUEST} ^GET\ .*/index\.(htm|html|php)\ HTTP
    RewriteRule ^(.*)index\.(htm|html|php)$ /$1 [R=301,L]
    [/php]
    if that doesn't work for any reasons, you can try using php
    [php]
    $host = $_SERVER;
    if(!stristr($host,"www.")){
    header("Location: http://www." . $host,true,301);
    exit();
    }
    [/php]

    Add the above code at the top of every page on your website (a common include file)


  • Registered Users Posts: 7,739 ✭✭✭mneylon


    Does your host have ISAPI rewrite available?


  • Registered Users Posts: 706 ✭✭✭DJB


    @louie @blacknight - what are we like? Christmas day and all! :D

    ISAPI Rewrite is the best option if your host has it but not all hosts have it on shared windows servers. I think blacknight provide it on theres, am I right?


  • Closed Accounts Posts: 1,200 ✭✭✭louie


    @DJB - Just keeping an eye on things and this tread came into my RSS notice...


  • Advertisement
  • Closed Accounts Posts: 112 ✭✭lostprophetsie


    louie wrote: »
    @DJB - Just keeping an eye on things and this tread came into my RSS notice...
    Yeah sorry guys with it being Xmas day and all your help has really been appreciated. I had a look at ISAPI rewrite but couldnt find anything from my hosting provider I might open a ticket with them and see what they have. Once again thank you very much louie, DJB and blacknight, I will have a look at all the options in the next few days, gonna leave it off for today :)
    Thanks again and Merry Xmas.


  • Registered Users Posts: 7,739 ✭✭✭mneylon


    DJB wrote: »
    I think blacknight provide it on theres, am I right?
    Yeah we do :P


  • Registered Users Posts: 706 ✭✭✭DJB


    Well, there you go lostprophetsie, if your hosting provider doesn't have it, have a look at moving to Blacknight.

    If you need help setting it up, let me know, I work with isapi rewrite on my iis server all the time and I've a small library of code built up.

    Rgds, Dave


Advertisement