user2997418
user2997418

Reputation:

php url without extension

My subject is different from the deprecated one, all I need is to get a string as URL without showing the PHP filename. I have items to click and to go to edit.php page I am trying to get a clicked string as URL.

e.g. if I click 'abc' , I want to go to the page edit.php and the browser displays :

http://localhost/abc 

not to

http://localhost/edit.php?item=abc

It's something like the routing in Symfony.

Upvotes: 1

Views: 203

Answers (1)

rjdown
rjdown

Reputation: 9227

Here is an example .htaccess file for your VERY SPECIFIC example above:

# turn on rewriting
RewriteEngine on

# check that the request isn't actually a real file (e.g. an image)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# redirect requests for BLAH to /edit.php?item=BLAH
RewriteRule ^(.*)$ /edit.php?item=$1 [NC,L]

Here are the docs you need for anything else http://httpd.apache.org/docs/2.0/misc/rewriteguide.html

Upvotes: 3

Related Questions