【问题标题】:How to Remove Project name From Url如何从 URL 中删除项目名称
【发布时间】:2016-07-24 21:26:21
【问题描述】:

我使用$locationProvider.html5Mode(true)从网址中删除了哈希标签

然后我尝试在我的 htcaccess 文件中使用以下代码解决刷新问题

Options +FollowSymlinks
RewriteEngine On
RewriteBase /test/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(css|js|html|png|jpg|jpeg|gif|txt)
RewriteRule (.*) index.html [L]

现在网址看起来像

http://diafriends.hostoi.com/test/
http://diafriends.hostoi.com/test/about
http://diafriends.hostoi.com/test/contact

现在我想从上面的 url 中删除 test。我该怎么做???

【问题讨论】:

  • 尝试删除RewriteBase
  • @Rayon Dabre 我试过了。它不工作。
  • 您需要使用根文件夹中的 htaccess 而不是测试。
  • @Rayon Dabre 我试过了。那也行不通。
  • @starkeen 我只将 htcaccess 文件放在根目录下。检查上面的屏幕截图。

标签: javascript jquery angularjs html .htaccess


【解决方案1】:

首先从您的文件夹中删除您的托管服务提供商的 default.php 文件,然后将以下内容添加到 htaccess 中:

Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(css|js|html|png|jpg|jpeg|gif|txt)
RewriteRule (.*) /test/index.html [L]

【讨论】:

    猜你喜欢
    • 2018-04-11
    • 1970-01-01
    • 2020-01-07
    • 2013-10-31
    • 2019-06-19
    • 2013-08-09
    • 1970-01-01
    相关资源
    最近更新 更多