0

For example, I have the following URL: www.site.com?page=products&action=view&id=1023 I have this PHP code:

<?php
echo $_GET['page'];
echo $_GET['action'];
echo $_GET['id'];
?>

That wors fine. But I want to rewrite the URL to

www.site.com/products/view/1023

So, the names of the arguments, and some characters like ? and & are removed. The URL would be:

www.site.com/products/view/1023

How do I say to PHP which GET variable I want to use? The names in the UL are away. I am making a PHP router, and I don't understand how parameters are passed by rewritten URL's.

Deepu
  • 11,425
  • 13
  • 53
  • 87
user2190492
  • 966
  • 2
  • 6
  • 30
  • What does your .htaccess look like? – Floris Dec 18 '13 at 13:04
  • I advise you to read this: http://www.sitepoint.com/guide-url-rewriting/ – Floris Dec 18 '13 at 13:08
  • 1
    The rewrite rule itself will specify the GET parameters you use. E.g. you create a rule to "rewrite" `www.site.com/products/view/1023` into `www.site.com?page=products&action=view&id=1023`, thus meaning that your PHP script doesn't need to change. I suggest you read a good tutorial on how to write such rules. – Rob Baillie Dec 18 '13 at 13:15

0 Answers0