[HELP] .htaccess

Discussion in 'PHP' started by CPAPubMichael, Feb 1, 2011.

  1. #1
    Hello,

    I am in need of some help from you .htaccess gurus. Well i have a link like this;

    http://www.example.com/track/index.php?pub=XXX&camp=XXX&subid1=XXX&subid2=XXX&subid3=XXX&subid4=XXX&subid5=XXX
    HTML:
    However, i would like the link to look similar to this:

    http://www.example.com/track/pub/XXX/camp/XXX/subid1/XXX/subid2/XXX/subid3/XXX/subid4/XXX/subid5/XXX
    HTML:
    I know there is a way to do this in .htaccess, i have tried and tried and tried but cannot seem to get it to work.

    Thank you for all your help and time in advance.

    Kind Regards,

    Michael
     
    CPAPubMichael, Feb 1, 2011 IP
  2. bartolay13

    bartolay13 Active Member

    Messages:
    735
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    98
    #2
    Try this one, when i pass variables to other page its like this,

    example 1:
    http://www.link.com/user/38
    RewriteRule ^user\//?(.*)$ /phpPage.php?user_id=$1 [L,QSA]

    example 2:
    http://www.link.com/user/38/11
    RewriteRule ^user\//?(.*)$ /phpPage.php?user_id=$1&category=$2 [L,QSA]

    no need to describe how it works, youll get it.
     
    bartolay13, Feb 1, 2011 IP
  3. mastermunj

    mastermunj Well-Known Member

    Messages:
    687
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    110
    #3
    Hi,

    I would suggest following link structure, it is more SEO friendly.

    
    http://www.example.com/track/pub-camp-subid1-subid2-subid3-subid4-subid5.html
    
    Code (markup):
    Each of above hyphen separated elements would be actual value and will make more sense to spiders as well. Also, if subid1 to subid5 are hierarchy of the categories or something, and can be traced back from only single id, then keep only the one in url, that will make the url short and better.

    rewrite rule for above url would be:

    
    RewriteRule ^([^-]*)-([^-]*)-([^-]*)-([^-]*)-([^-]*)-([^-]*)-([^-]*)\.html$ /track/index.php?pub=$1&camp=$2&subid1=$3&subid2=$4&subid3=$5&subid4=$6&subid5=$7 [L]
    
    Code (markup):
     
    mastermunj, Feb 2, 2011 IP