.htaccess help needed - dynanmic redirect

Discussion in 'Programming' started by DomainMagnate, Sep 26, 2009.

  1. #1
    Hey all!

    Need some help to redirect the old file structure to new, several lines:

    old: site/default.php?page=uk01
    new: site/txt/uk01.php

    old:site/default.php?page=us01
    new:site/txt/aus01.php


    01 means there are many pages like this with 01, 02, 03 etc.

    Please post the .htaccess file I should use to redirect the old queries to new pages

    thanks!
     
    DomainMagnate, Sep 26, 2009 IP
  2. Bohra

    Bohra Prominent Member

    Messages:
    12,573
    Likes Received:
    537
    Best Answers:
    0
    Trophy Points:
    310
    #2
    Options +FollowSymLinks
    RewriteEngine on
    RewriteRule /txt/(.*)\.php$ /default.php?page=$1

    that should do the trick
     
    Bohra, Sep 27, 2009 IP
  3. chadsmith

    chadsmith Peon

    Messages:
    82
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Try

    RewriteEngine On
    RewriteBase /
    
    RewriteCond %{QUERY_STRING} ^page=([a-z0-9]+)$
    RewriteRule ^default\.php$ /txt/%1.php? [R=301,L]
    Code (markup):
    This would redirect

    yourdomain.com/default.php?page=anything123

    to

    yourdomain.com/txt/anything123.php
     
    chadsmith, Sep 27, 2009 IP
  4. DomainMagnate

    DomainMagnate Illustrious Member

    Messages:
    10,932
    Likes Received:
    1,022
    Best Answers:
    0
    Trophy Points:
    455
    #4
    I tried a few .htaccess, but couldn't get this to work, so just did a php redirect in the end.
     
    DomainMagnate, Sep 30, 2009 IP