删除扩展名为.php的网址 [英] Remove .php extension from url

查看:147
本文介绍了删除扩展名为.php的网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从URL中删除扩展名为.php和查询字符串,以及通过重写URL 我知道这可以在.htaccess文件中完成 我有这个在我的.htaccess文件至今

I am required to remove .php extension and query string as well from url by rewriting the url I know this can be done in .htaccess file I have this in my .htaccess file so far

            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扩展以及 这必须通过此网址访问 example.com/blog/post/13/comment/3

now the url example.com/blog.php?post=12&comment=3 can be accessed by example.com/blog.php/post/12/comment/3 but i want to remove .php extension as well this must be accessible through this url example.com/blog/post/13/comment/3

任何帮助吗?

感谢你在前进。

推荐答案

搜索一切除了 /

RewriteRule ^(([^/]+/)*[^.]+)$ /$1.php [L]

这篇关于删除扩展名为.php的网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆