0

There is a rewrite rule ensuring that all URL's head to index.php and maintain a 'pretty format'.

I still need to get information from them to work out what page to send the user.

Say there is a Url

http://localhost/telephones/nokia

I need to find out the SQL table ('telephone') and the make ('nokia')

How do I do that.

UPDATE

RewriteEngine on
RewriteRule ^/([^/]+)/([^/]+) /index.php?table=$1&make=$2 [NC]

(in .htaccess)

$table = $_GET['table']; $make = $_GET['make'];
$CONsiteurl = mysql_query("SELECT * FROM $table WHERE name = $make");

So we can bring up the page now by typing in http://localhost/?make=nokia&table=telephones but cannot get to it by typing in http://localhost/telephones/nokia

Why

3
  • What is the current rewrite rule? Commented Jun 15, 2012 at 22:55
  • The rewrite rule sends everything to index.php from which I've tried an explode on the slashes and foreach on the results. Not very good or flexible. Commented Jun 15, 2012 at 22:58
  • Are you sure your .htaccess file is actually being used? To make sure, just add a Deny from all clause to it and see if you get a 403. Commented Jun 16, 2012 at 1:27

1 Answer 1

1

Assuming you have mod_rewrite setup you can put something like this in you .htaccess:

RewriteEngine on
RewriteRule ^/([^/]+)/([^/]+) /index.php?table=$1&make=$2 [NC]

Then you can access the values from php using $_GET('table') etc.

Sign up to request clarification or add additional context in comments.

3 Comments

This just says page not found. I have tried it but I do not understand how it is supposed to work. I have made a page called localhost/pages/sample-page. I can get to it by typing in localhost?table=pages&make=sample-page but not by typing in the 'pretty url'
corz.org/serv/tricks/htaccess2.php or some other tutorial you can find at at a search engine near you.
Shown you my entire process in question. Exactly as in documentation but not working. Please help

Your Answer

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.