【发布时间】:2014-10-23 20:37:38
【问题描述】:
您能否告诉我如何在 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
但这只会删除扩展名。谢谢
【问题讨论】:
-
请不要这样做。您无法在内容中创建深层链接,从而提供了糟糕的用户体验。
-
为什么要这样做?也许你可以用另一种方式完成你想要的。
标签: javascript php jquery html url-rewriting