.htaccess将.php重写为'virtual folder'

Mic*_*ers 0 php .htaccess rewrite

可能重复:
使用.htaccess删除.php扩展名

我有

http://www.example.com/test/categoryform.php
Run Code Online (Sandbox Code Playgroud)

在我的.htaccess文件中,如何重写它以显示为:

http://www.example.com/test/categoryform/
Run Code Online (Sandbox Code Playgroud)

Nul*_*teя 5

试试这个代码吧

RewriteEngine On
# turn on the mod_rewrite engine

RewriteCond %{REQUEST_FILENAME}.php -f
# IF the request filename with .php extension is a file which exists
RewriteCond %{REQUEST_URI} !/$
# AND the request is not for a directory
RewriteRule (.*) $1\.php [L]
# redirect to the php script with the requested filename
Run Code Online (Sandbox Code Playgroud)

如何隐藏.PHP在.htaccess扩展问题也是有用的