【问题标题】:Hide main.html from header redirection从标头重定向中隐藏 main.html
【发布时间】:2016-09-26 06:59:53
【问题描述】:

我有一个使用标头重定向到 main.html 的 php 文件。 我需要从看起来像'https://mywebsite.com/main.html`的网址中隐藏main.html`

因此,在显示 main.html 的内容时,它看起来像 https://mywebsite.com

【问题讨论】:

    标签: php html .htaccess


    【解决方案1】:

    您可以在根 .htaccess 中使用这些规则:

    RewriteEngine On
    
    # if main.html has been sent in original request then redirect to home page
    # THE_REQUEST variable represents original request received by Apache from your browser
    # and it doesn't get overwritten after execution of some rewrite rules
    RewriteCond %{THE_REQUEST} /main\.html[\s?] [NC]
    RewriteRule ^main\.html$ / [L,R=301,NC]
    
    # load main.html for landing page
    RewriteRule ^/?$ main.html [L]
    

    【讨论】:

    • 你为什么用THE_REQUEST 而不是REQUEST_URI
    • 增加了使用THE_REQUEST的解释和原因
    猜你喜欢
    • 2021-07-22
    • 2013-12-30
    • 1970-01-01
    • 1970-01-01
    • 2017-08-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多