2

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.

pinkpanther
4,8083 gold badges41 silver badges63 bronze badges
asked Jun 7, 2013 at 13:55

3 Answers 3

8

You need to use .htaccess like so:

RewriteEngine on
RewriteCond %{REQUEST_URI} !-f
RewriteCond %{REQUEST_URI} !-d
RewriteRule (.*) /?value=1ドル [L]
answered Jun 7, 2013 at 13:57

4 Comments

Please clarify me on more thing after doing that how can we get the value . I mean where to write the code. In index.php or where..?
In index.php, you should access $_GET['value'].
I have added the code in ht access file and uploaded into server. My path is like 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
Because it was my understanding you were in the root folder. Try removing the slash before the ? (so just ?value=1ドル) - I'm not sure if it'll work or not, but it's something to try first!
1

you need to add re-write rule to rewrite the add this rule in .htaccess

 RewriteEngine on
 RewriteRule /(.*) /?value=1ドル [L]
answered Jun 7, 2013 at 14:00

Comments

0

Assuming Apache:

  • Map / onto your script with Alias
  • Examine $_SERVER['PATH_INFO']

e.g.

Alias / /home/site/myphp.php/

and

echo htmlspecialchars($_SERVER['PATH_INFO']);
answered Jun 7, 2013 at 13:59

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.