Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

301 Redirect

  • 25-12-2008 04: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, Registered Users 2 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, Registered Users 2 Posts: 7,742 ✭✭✭mneylon


    Does your host have ISAPI rewrite available?


  • Registered Users, Registered Users 2 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, Registered Users 2 Posts: 7,742 ✭✭✭mneylon


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


  • Registered Users, Registered Users 2 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