【发布时间】:2012-03-16 11:42:26
【问题描述】:
我需要通过重写 url 从 url 中删除 .php 扩展名和查询字符串 我知道这可以在 .htaccess 文件中完成 到目前为止,我的 .htaccess 文件中有这个
RewriteEngine on
DirectoryIndex Home.html
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) $1\.php [L]
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.html
RewriteRule .* Home.html
现在是网址 example.com/blog.php?post=12&comment=3 可以通过 example.com/blog.php/post/12/comment/3 但我也想删除 .php 扩展名 这必须可以通过这个 url 访问 example.com/blog/post/13/comment/3
有什么帮助吗?
提前谢谢你。
【问题讨论】: