【问题标题】:How to remove /index from url如何从 url 中删除 /index
【发布时间】:2020-11-11 06:47:46
【问题描述】:

我编写了自己的网站,我想成为主页上的 https://example.com/index 我可以通过向 .htaccess 添加一些内容来删除 .html,但我无法摆脱 /index。我使用 Heroku 来托管我的网站。它使用所有代码连接到我的 GitHub 存储库,每当我将更改推送到 GitHub 时,它都会自动部署网站。还有什么我可以添加到 .htaccess 文件或者重命名 index.html 之类的吗?

【问题讨论】:

    标签: php html url heroku


    【解决方案1】:

    将以下代码添加到您的 .htaccess 文件中。这样就可以了

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule (.*) /index.php/$1 [L]
    

    【讨论】:

    • 这样做没有用。现在,当我想去我的关于页面或任何其他页面时,它不再起作用。它只是重定向回再次有 /index.html 的主页
    猜你喜欢
    • 2014-04-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-14
    相关资源
    最近更新 更多