【问题标题】:Removing 'index.html' from my re-directed PHP website url从我重定向的 PHP 网站 url 中删除 'index.html'
【发布时间】:2016-09-14 07:41:24
【问题描述】:

我正在使用 Heroku 来部署我的网站,并通过包含一个简单地路由到我的 index.html 的 index.php 文件来欺骗它认为我的静态网站是一个动态网站。我这样做是为了简单地将我的网站托管在 Heroku 上,显然它通常不托管静态网站,只是动态网站(据我所知)。

问题:如何删除出现在我网站末尾的 index.html:www.roberttassy.co/index.html?在我的代码中,我有一个 index.php 文件,其中包含代码块:

<?php header( 'Location: /index.html' ) ; ?>

它成功地重新路由到我的 index.html 文件,但我只是不希望“index.html”出现在地址栏中的我的 url 中。我希望它只是阅读:www.roberttassy.co。有什么建议吗?

【问题讨论】:

  • devcenter.heroku.com/articles/custom-php-settings 按照上面的设置创建一个基于 apache 的服务器,然后使用 .htaccees 文件重写 url,google 一下就很容易了!
  • 谢谢!我发现使用替换我的php代码 更容易;-P

标签: php .htaccess heroku deployment routing


【解决方案1】:

试试这个

<?php include 'index.html';?>

【讨论】:

  • 给了你绿色检查,因为它需要的代码略少,呵呵。
  • 小代码?以什么方式大声笑,你可以删除我的括号,它会是一样的
  • 那你为什么不这样提交?!底线:代码更少。
【解决方案2】:

尝试改用它。

&lt;?php require("index.html"); ?&gt; 而不是标题。

【讨论】:

    猜你喜欢
    • 2017-08-11
    • 2019-05-27
    • 1970-01-01
    • 1970-01-01
    • 2017-01-16
    • 1970-01-01
    • 2015-09-27
    • 2014-04-24
    • 2016-01-26
    相关资源
    最近更新 更多