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 help please... .htaccess

  • 09-07-2009 12:50PM
    #1
    Registered Users, Registered Users 2 Posts: 461 ✭✭


    Hi,

    i want to do a simple 301 redirect (page has permanently moved) within .htaccess

    The model I found is:
    redirect 301 about/contact-us http://www.mysite.com/about/contact-mycompany
    

    However - I have other sites at this level and can't redirect all about/contact-us to this new page.

    i need the equivalent of:
    code:
    redirect 301 http://www.mysite.com/about/contact-us http://www.mysite.com/about/contact-mycompany

    to be clear on which domain/site to act on.
    (This code doesn't work...)
    So it's full path to full path and not relative to full path as per first example.

    I can't for the life of me find a solution via google etc...

    Anyone done this before? All help appreciated!


Comments

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


    if you can't get it to work using the .htaccess try php
    [php]
    //array of pages allowed - don't forget to include the redirection page
    //in this case redirect.html
    $allow_url = array("/page1.html", "/page2.html","/redirect.html");
    $get_uri = $_SERVER;
    //print_r($allow_url);
    if(!in_array($get_uri,$allow_url)){
    header("Location: yourpage-here.html", true, 301);//301=permanent - 302=temporary
    exit();
    }
    [/php]


  • Registered Users, Registered Users 2 Posts: 3,782 ✭✭✭Scotty #


    I presume you are using Apache? If so this should work...
    Options +FollowSymLinks
    RewriteEngine on
    RewriteRule (.*) http://www.[COLOR=Red]newdomainhere.com[/COLOR]/$1 [R=301,L]
    


  • Registered Users, Registered Users 2 Posts: 3,782 ✭✭✭Scotty #


    Oops you're only doing one page....
    However - I have other sites at this level and can't redirect all about/contact-us to this new page.
    Can't you place the .htaccess in the directory of the contact_us you DO want to redirect?


  • Registered Users, Registered Users 2 Posts: 461 ✭✭Howitzer


    cheers for the replies.

    There is no 'directory' or 'file' to place in. Using code igniter.

    I could put something in php somewhere.

    Would prefer to get the htaccess version.

    Shame it just won't play ball! Ah well - no panic. cheers for the help.


Advertisement