Results 1 to 6 of 6

 

Thread: 301 redirects?

  1. #1
    25 chars.? Need more spac

    Status
    Offline
    Join Date
    Aug 2003
    Location
    here
    Posts
    133
    Thanks
    0
    Thanked 0 Times in 0 Posts


    I have recently registered a shed load of domains and walloped together "mini sites", using info that was previously part of our main directory site - i.e. instead of http://www.mainsite.co.uk/bananas there is now http://www.minibananasite.co.uk (with the previous directory "bananas" now pointing at the new site).

    All of this is fine and dandy, however under the old site I had a set up like:

    http://www.mainsite.co.uk/bananas/details.php?q=bananaretailer1 - this would then give a lovely optimised page that details all about "bananaretailer1" - what I would like to do is automatically redirect this to the new site, but I really haven't got a Scooby, to utilise the language of my 4-year old...

    I understand that a 301 within a .htaccess goes something like:

    Redirect 301 /page.php http://www.newsite.co.uk/newpage.php

    However I would like to make:

    http://www.mainsite.co.uk/bananas/details.php?q="WHATEVER"

    resolve to

    http://www.minibananasite.co.uk/details.php?q="WHATEVER"

    where the bit after q= is a variable, as opposed to a constant string..

    Please can someone put me out of my misery?

    Cheers

  2. #2
    loquax's Avatar
    www.onelittleduck.co.uk

    Status
    Offline
    Join Date
    Aug 2003
    Location
    Swansea
    Posts
    2,804
    Thanks
    45
    Thanked 163 Times in 92 Posts
    Have you tried

    Redirect 301 /bananas/ http://www.minibananasite.co.uk/

    think that should work?

    Jason

  3. #3
    25 chars.? Need more spac

    Status
    Offline
    Join Date
    Aug 2003
    Location
    here
    Posts
    133
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks Jason - that is what we are doing for the "main" directories - the problem was with redirecting variables as opposed to a static constant - e.g. if someone clicks on a link to

    http://www.oldsite.com/olddirectory/search.php?q=WHATEVER&order=WHATEVER

    they are automatically redirected to:

    http://www.newsite.com/newsearch.php?q=WHATEVER&order=WHATEVER

    If it helps, there are only a couple of these types of files, they are all php, so I suppose I could edit the existing PHP file - which would lead to a further question - "How would one go about making dynamic php redirects" -

    e.g.

    1) Create a file called "details.php", which takes the bit after q=

    <?

    $details=$q;

    echo $site[$details]."";

    ?>

    2) Call the output of details.php within the header of

    <?
    include ("details.php");
    Header ("Location: http://www.site2.co.uk/search.php?q=$details"); ?>

    The problems with this are threefold:

    1. The Header function cannot be used, as a header has already been called

    2. "fopen" would expect more than 1 variable, and

    3. I haven't really got the foggiest about what I am doing

    If there is a simple "write this page" function that can be used instead of Header , above I would probably be on my way...

    Apologies for the rambling once again...

  4. #4
    Super Member

    Status
    Offline
    Join Date
    Aug 2003
    Location
    Costa Del Sheffield
    Posts
    2,838
    Thanks
    5
    Thanked 18 Times in 14 Posts
    edit search.php to contain

    <?

    $url = "http://www.newsite.com/newsearch.php?q=$q&order=$order";

    header ("Location: $url"); ?>

    that should work
    Dan Morley
    alpharooms.com
    daniel at alpharooms dot com - Hotels, Flights, Airport Transfers, Care Hire + More! sign up
    My Blog | Cheap Holidays

  5. #5
    25 chars.? Need more spac

    Status
    Offline
    Join Date
    Aug 2003
    Location
    here
    Posts
    133
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That is spot-on, thanks hugely!

    The best bit is that I can see why it works too - thanks again..

  6. #6
    Super Member

    Status
    Offline
    Join Date
    Aug 2003
    Location
    Costa Del Sheffield
    Posts
    2,838
    Thanks
    5
    Thanked 18 Times in 14 Posts
    no problemo
    Dan Morley
    alpharooms.com
    daniel at alpharooms dot com - Hotels, Flights, Airport Transfers, Care Hire + More! sign up
    My Blog | Cheap Holidays



Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
To Top

Content Relevant URLs by vBSEO 3.5.0 RC2