【问题标题】:Can I hide part of a page's filename from displaying in the URL bar?我可以隐藏页面文件名的一部分,使其不显示在 URL 栏中吗?
【发布时间】:2016-01-07 05:15:44
【问题描述】:

假设我的网站上有四个页面:001-earth.php002-water.php003-fire.php004-air.php

我想在编辑我的网站时以特定顺序显示这些文件,为了我自己的方便,这就是我在文件名中添加数字的原因。但我不希望我网站的访问者在访问该页面时看到这些数字。我想隐藏浏览器地址栏中的数字和破折号。

我的问题是:是否可以从 URL 中隐藏数字(001-002- 等),但不能从文件名中删除它们,以便当有人访问位于 @987654328 的文件时@,浏览器的地址栏居然显示http://example.com/earth.php

如果是这样,怎么做?

【问题讨论】:

标签: php .htaccess url url-rewriting


【解决方案1】:

尝试在 .htaccess 中添加以下内容:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^/?earth.php /001-earth.php [L]
    RewriteRule ^/?water.php /002-water.php [L]
    RewriteRule ^/?fire.php /003-fire.php [L]
    RewriteRule ^/?air.php /004-air.php [L]
</IfModule>

【讨论】:

  • 没问题,也不要忘记“up”帖子。谢谢!
猜你喜欢
  • 2011-10-12
  • 1970-01-01
  • 2023-04-11
  • 2020-10-25
  • 2021-06-29
  • 2020-10-15
  • 1970-01-01
  • 2015-11-29
  • 1970-01-01
相关资源
最近更新 更多