【问题标题】:.htaccess serve index.html under all urls.htaccess 在所有 url 下服务 index.html
【发布时间】:2018-11-05 10:25:44
【问题描述】:

是否有可能重写 .htaccess 以将所有请求指向 index.html 但不更改 url?

我找到了一个规则,将所有请求重定向到 index.html,但是在这种情况下,url 发生了变化:

RewriteEngine on
RewriteCond %{REQUEST_URI} !^/index.html$
RewriteRule . /index.html [R=302,L]

是否可以将所有 url 地址指向 index.html 但保留原始 url?

mydomain.com/foo -> display index.html (address stays)

如何做到这一点?

【问题讨论】:

  • 非常简单。只需删除 R=302 标志即可。
  • @starkeen 就是这样。如果您想在下面发布,我会将您的答案标记为解决方案。谢谢。

标签: apache .htaccess


【解决方案1】:

R 标志进行外部重定向。如果您不想重定向 url,只需从规则中删除标志

RewriteEngine on
RewriteCond %{REQUEST_URI} !^/index.html$
RewriteRule . /index.html [L]

【讨论】:

    猜你喜欢
    • 2011-07-31
    • 2017-07-21
    • 2018-06-20
    • 2014-05-13
    • 2013-02-17
    • 1970-01-01
    • 1970-01-01
    • 2020-09-14
    • 1970-01-01
    相关资源
    最近更新 更多