如何在URL中屏蔽扩展名 [英] How to Mask Extension in URL
本文介绍了如何在URL中屏蔽扩展名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以使用PHP屏蔽网站上页面的URL扩展? 例如: http://home/subfolder 而不是 http://home.subfolder.php
Is there a way to mask the URL extensions for pages on my website with PHP? Example: http://home/subfolder instead of http://home.subfolder.php
推荐答案
在网站根目录的.htaccess文件中放置以下内容
Place the following in the .htaccess file in the root of your website
<IfModule mod_rewrite.c>
Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([^\.]+)$ $1.php [NC,L]
</IfModule>
这篇关于如何在URL中屏蔽扩展名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文