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
Hi all,
Vanilla are planning an update to the site on April 24th (next Wednesday). It is a major PHP8 update which is expected to boost performance across the site. The site will be down from 7pm and it is expected to take about an hour to complete. We appreciate your patience during the update.
Thanks all.

301 redirect help please... .htaccess

  • 09-07-2009 12:50pm
    #1
    Registered Users 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 Posts: 3,767 ✭✭✭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 Posts: 3,767 ✭✭✭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 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