【问题标题】:Masking URL in HTMLHTML 中的屏蔽 URL
【发布时间】:2016-08-02 11:07:44
【问题描述】:

我有一个 HTML 页面。假设 URL 是

http://localhost/local/local.html 

但我想将 URL 屏蔽为

http://localhost/local/abc

我们可以这样做吗?

【问题讨论】:

  • 总是带着问题发表你的努力
  • @utility .....我怀疑这是否可能。如果可能怎么做?

标签: url-masking


【解决方案1】:

在您的域根目录中创建一个.htaccess 文件,并在该文件中添加以下内容:

RewriteEngine On
RewriteRule ^local.html$ http://localhost/local/abc/ [R=301,L]

【讨论】:

  • 您不必创建abc.htaccess,只需创建没有名称的简单.htaccess。如果出现错误说Invalid File Name,那么只需创建一个新文件并将名称命名为.htaccess.(请注意,“htaccess”之前和之后都有一个句点
  • 我正在使用 IIS,在 wwwroot 文件夹中我创建了“.htaccess”(.),并且我将上面的代码添加为 RewriteEngine On RewriteRule ^Ifa_Reportsmry.cshtml$ @987654321 @ [R=301,L] 网址为:localhost/svymanalysis/Ifa_Reportsmry.cshtml
  • 上述解决方案适用于 apache web 服务器。如果您使用的是 IIS,请参考这个 stackoverflow 问题:stackoverflow.com/questions/25997830/…
  • 我会检查...谢谢
【解决方案2】:

.htaccess 中添加行:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*) index.php?query=$1 [QSA,L]

当您在index.php 中访问https://localhost/local/abc 时,请按照您的需要解析$_GET["query"]

【讨论】:

    【解决方案3】:

    您可以使用htaccess 规则实现所需的操作,

    了解 htaccess:

    What is .htaccess file?

    .htaccess 可以实现的规则如下:

    Options +FollowSymlinks
    RewriteEngine on
    rewriterule ^local/local.html (.*)$ http://localhost/local/abc$1 [r=301,nc]
    

    【讨论】:

      猜你喜欢
      • 2014-12-19
      • 1970-01-01
      • 1970-01-01
      • 2014-03-09
      • 1970-01-01
      • 2014-07-13
      • 2012-06-27
      • 2015-02-19
      • 1970-01-01
      相关资源
      最近更新 更多