1

I think this has been discussed over here in past but i don't know exactly what i have to search for so please if you could help just give me a hand. Well i want to create a url rewrite with multiple options. I cannot explain here with few so i would rather give a simple example. A url:

    example.com/info.php?id=1
    example.com/info.php?id=1&edit

I want to rewrite to like this

    example.com/info/1
    example.com/info/1/edit
WMax
  • 21
  • 2
  • possible duplicate of [htaccess rewrite for query string](http://stackoverflow.com/questions/1231067/htaccess-rewrite-for-query-string) – Machavity Nov 10 '14 at 19:41
  • I guess it is not and i already tried creating the rule with existing info or articles. – WMax Nov 10 '14 at 19:47

1 Answers1

0

I think you want the opposite: example.com/info/1 -> example.com/info.php?id=1

RewriteEngine on
RewriteRule ^info/([^/]+)/edit/?$ info.php?id=$1&edit   [L]
RewriteRule ^info/([^/]+)/?$    info.php?id=$1  [L]
Croises
  • 18,570
  • 4
  • 30
  • 47
  • No, i want example.com/info/1/edit -> example.com/info.php?id=1&edit Also id can be numberic and alphabetic. – WMax Nov 10 '14 at 19:54
  • Alright that worked but what about if there are 2 id like id=1&userid=2 – WMax Nov 10 '14 at 20:29
  • 1
    For me, the best solution is to send all the link to the PHP page, and take values after. But you can also add (before) 2 or 3 in the htaccess `RewriteRule ^info/([^/]+)/([^/]+)/?$ info.php?id=$1&other=$2` [L] – Croises Nov 10 '14 at 20:38