Reputation: 23
I am working on a website on which user can see the menu items of a particular Restaurant.
Every Restaurant Contains a unique ID and name
Example : Name -> Taj
Id -> 1111
Now what user want to do is along with the website link (ex: www.abc.com) he want give the id or name of any particular restaurant exactly in the below format
www.abc.com/1111 or www.abc.com/Taj
Then based on that ID or Name we want to display the menu items.
If the user is giving the value in the below format
www.abc.com/value=1111 or www.abc.com/value=Taj
then we can use the GET Method as below.
$value=$_GET['value'];
Code for Printing the menus come here..!!
But the Client requirement is like www.abc.com/1111
So if the user give like that the server will check for 1111 folder or Taj Folder. we will get the error File Not Found.
Anyone have the solution for this please Suggest me.
Upvotes: 2
Views: 2841
Reputation: 1556
you need to add re-write rule to rewrite the add this rule in .htaccess
RewriteEngine on
RewriteRule /(.*) /?value=$1 [L]
Upvotes: 1
Reputation: 943099
Assuming Apache:
/
onto your script with Alias
$_SERVER['PATH_INFO']
e.g.
Alias / /home/site/myphp.php/
and
echo htmlspecialchars($_SERVER['PATH_INFO']);
Upvotes: 0
Reputation: 324600
You need to use .htaccess
like so:
RewriteEngine on
RewriteCond %{REQUEST_URI} !-f
RewriteCond %{REQUEST_URI} !-d
RewriteRule (.*) /?value=$1 [L]
Upvotes: 8