简体   繁体   中英

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.

eg 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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM