SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2004
    Location
    Uruguay
    Posts
    74
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problem replacing query string

    The url I want to redirect is:

    http://hostname/en/guides?country=275

    ...and I want to redirect to:

    http://hostname/search/275

    My rules is:

    RewriteCond %{QUERY_STRING} ^country=(.*)$ [NC]
    RewriteRule ^en/guides /search/%1 [NC,L,R=301]

    ... but the query string replacement is not working.
    Do you know what's wrong with it ?

    Thanks.

  2. #2
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,653
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    Rata,

    Well, your mod_rewrite code should work ... despite the four pedantic things I find objectionable with it. Of course, that assumes an Apache 2.x server and a test URL of precisely hostname/en/guides?country=275 AND that mod_rewrite is enabled and operates out of the .htaccess file (standard).

    Do you have any other mod_rewrite before this which could hijack the URI (using (.*) where it's inappropriate leads me to believe that the answer is probably yes). If so, please display ALL your mod_rewrite code so the conflicts can be uncovered.

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator


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
  •