php网址没有扩展名

时间:2014-10-29 17:56:58

标签: php .htaccess url-rewriting

我的主题与弃用的主题不同,我只需要将字符串作为URL而不显示PHP文件名。 我有点击的项目,然后去edit.php页面 我试图将一个单击的字符串作为URL。

e.g。如果我点击' abc' ,我想转到页面edit.php,浏览器显示:

http://localhost/abc 

不要

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

它类似于Symfony中的路由。

1 个答案:

答案 0 :(得分:3)

以下是您上面非常具体示例的示例.htaccess文件:

# 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]

以下是其他任何内容所需的文档http://httpd.apache.org/docs/2.0/misc/rewriteguide.html