Why is my rewrite rule failing?

Discussion in 'Apache' started by laredotornado, Oct 8, 2010.

  1. #1
    Hi,

    I have a URL

    http://mydomain/accommodations/hotel-details?id=4044&offerId=602

    that I want to be rewritten as

    http://mydomain/accommodations/hotel-details/4044/package/602

    However, this rewrite rule is not doing the job. I'm guessing my use of regular expressions is somehow failing and ask the group for advice ...

    RewriteRule ^/accommodations/hotel-details?id=(.*)&offerId=(.*)$ /accommodations/hotel-details/$1/package/$2 [R=301,L]

    Thanks, - Dave
     
    laredotornado, Oct 8, 2010 IP
  2. MrYu

    MrYu Peon

    Messages:
    157
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Try this, you need to escape ? and .* matches too much:

    RewriteRule ^/accommodations/hotel-details\?id=(\d+)&offerId=(\d+)$ /accommodations/hotel-details/$1/package/$2 [R=301,L]
     
    MrYu, Oct 12, 2010 IP