1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Help with rewrite?

Discussion in 'Apache' started by RacerWeek, Sep 19, 2005.

  1. #1
    Can anyone help me with the mod rewrite, I've tried the one posted here with no luck

    I'm trying to change this url:

    http://www.mysite.com/tags/pivot/entry.php?id=8&t=a.html&tag=SOMETAG
    Code (markup):
    to

    http://www.mysite.com/tags/SOMETAG
    Code (markup):
    I've tried this, but with no luck:

    RewriteRule ^tags/(.*)$ pivot/entry.php?id=8&tag=$1

    Can anyone helpe me out? My .htaccess is in the root dir.
     
    RacerWeek, Sep 19, 2005 IP
  2. johnt

    johnt Peon

    Messages:
    178
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Try
    RewriteCond ! pivot/entry.php
    RewriteRule ^tags/(.*)$ /tags/pivot/entry.php?id=8&t=a.html&tag=$1 [L]
    
    Code (markup):
     
    johnt, Sep 20, 2005 IP
  3. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #3
    domain.com/.htaccess

    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^tags/([^.]+)$ pivot/entry.php?id=8&tag=$1 [L]

    That's only if you always want the id to be 8. if you want

    http:--www.mysite.com/tags/pivot/entry.php?id=8&t=a.html&tag=SOMETAG
    changed, and always have id=8&t=a.html in it.....

    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^tags/([^.]+)$ tags/pivot/entry.php?id=8&t=a.html&tag=$1 [L]


    domain.com/tags/pivot/entry.php?id=8&t=a.html&tag=ANYTHING
    to
    domain.com/tags/ANYTHING
     
    Nintendo, Sep 20, 2005 IP
  4. fryman

    fryman Kiss my rep

    Messages:
    9,604
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    370
    #4
    Mister mod rewrite to the rescue again! :D
     
    fryman, Sep 20, 2005 IP
  5. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #5
    Ack!!!! HOW DARE YOU CALL ME MISTER!!!!!!!!! Next time call me Wacko mod_rewrite!!! [​IMG] [​IMG] [​IMG] [​IMG]

    gah.... I hate compliments!!!!
     
    Nintendo, Sep 20, 2005 IP
  6. fryman

    fryman Kiss my rep

    Messages:
    9,604
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    370
    #6
    Sorry, mister wacko! :p
     
    fryman, Sep 20, 2005 IP
  7. programmer

    programmer Guest

    Messages:
    444
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #7
    programmer, Sep 20, 2005 IP
  8. RacerWeek

    RacerWeek Peon

    Messages:
    165
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Nintendo, thank you so much - it worked! :)

    Now i realize that I want to make it look like an html file, so that the final output would be like this:

    http://www.mysite.com/tags/SOME_LONG_TAG.html
    Code (markup):
    from a url like this
    http://www.mysite.com/tags/pivot/entry.php?id=8&t=a.html&tag=SOME+LONG+TAG
    Code (markup):
    So basically, I just want to add a way to map to ".html" and replace "+" with "_"

    sorry to be so noobish, thanks for everyones help.
     
    RacerWeek, Sep 20, 2005 IP
  9. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #9
    RewriteRule ^tags/([^.]+)$
    to
    RewriteRule ^tags/([^.]+).html$

    >replace "+" with "_"

    You'll have to edit the script to search for the + and replace it with a _. I'm only a pro at that in perl.
     
    Nintendo, Sep 20, 2005 IP
  10. RacerWeek

    RacerWeek Peon

    Messages:
    165
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Ok, everthing works great, thanks again for you help!

    The only thing I noticed is that if I'm on the page:
    http://www.mysite.com/tags/SOME_LONG_TAG.html

    and click on a link, it maps back to the old long url. Is there anyway to prevent that with the .htaccess?

    thanks again.
     
    RacerWeek, Sep 20, 2005 IP
  11. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #11
    You have to edit the script to change the links. mod_rewrite doesn't magically edit the script to make the links link to the new URLs!!!!! :D:D
     
    Nintendo, Sep 20, 2005 IP