Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Oct 2002
    Posts
    299
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Htaccess - rewrite url with arguments to dir structure

    Hi,

    I would like to rewrite (engine is on) some url with arguments to a directory structure like:

    http://www.mysite.com/?brand=sony to http://www.mysite.com/sony/

    Thanks for your help,

  • #2
    New Coder
    Join Date
    Feb 2007
    Posts
    43
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Try this!

    RewriteCond %{QUERY_STRING} brand=sony
    RewriteRule ^(.*)$ http://www.mysite.com/sony/ [QSA,L]

  • #3
    Regular Coder
    Join Date
    Oct 2002
    Posts
    299
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks Pramit,

    Unfortunately, I got a 500 server error with it....

    Is it also possible to have different redirects, e.g.

    ?brand=sony to /sony/

    ?brand=philips to /philips/

    and so on

    Thanks,

  • #4
    New Coder zfred09's Avatar
    Join Date
    Dec 2006
    Posts
    69
    Thanks
    0
    Thanked 5 Times in 5 Posts
    Yes it is, try something like this.

    Code:
    RewriteEngine on
    RewriteRule ^([0-9a-zA-Z_]+)*/?$ /index.php?brand=$1 [L]
    This should rewrite a url like yoursite.com/?brand=sony to yoursite.com/sony/. In the code index.php is the page you would like to direct it to (I assumed index) and brand is the name of the $_GET variable you are using.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •