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.
3 Answers 3
You need to use .htaccess
like so:
RewriteEngine on
RewriteCond %{REQUEST_URI} !-f
RewriteCond %{REQUEST_URI} !-d
RewriteRule (.*) /?value=1ドル [L]
4 Comments
index.php
, you should access $_GET['value']
.www.abc.com/resturents
. All the files of project is in that folder restuarents
. So i have uploaded there. Now if am giving like www.abc.com/resturents/1111 then it is displaying the content of root folder files means (www.abc.com). Why it is happening like that?
(so just ?value=1ドル
) - I'm not sure if it'll work or not, but it's something to try first!you need to add re-write rule to rewrite the add this rule in .htaccess
RewriteEngine on
RewriteRule /(.*) /?value=1ドル [L]
Comments
Assuming Apache:
- Map
/
onto your script withAlias
- Examine
$_SERVER['PATH_INFO']
e.g.
Alias / /home/site/myphp.php/
and
echo htmlspecialchars($_SERVER['PATH_INFO']);