您能否让我知道如何在PHP或HTML中将网页名称隐藏起来?例如,如果我有这样的:从URL中隐藏文件名
www.mydomain.com/about.html
www.mydomain.com/project.html
www.mydomain.com/contact.php
只显示为:
www.mydomain.com
我已经看到了使用
这一招以下内容添加到您的.htaccess
文件:
#######
#Allow PHP/HTML pages to load without the filename extension
######
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html
但这只能删除扩展名。谢谢
请不要这样做。您无法在您的内容中创建深层链接,从而提供了令人恐怖的用户体验。 – Hirnhamster 2014-08-29 19:56:01
你为什么想这样做?也许你可以用另一种方式完成你想要的东西。 – Dehli 2014-08-29 20:15:11