【问题标题】:htaccess not updating on the server?htaccess 不在服务器上更新?
【发布时间】:2021-05-29 16:21:24
【问题描述】:

我有点不知所措。我在一个网站上工作,所以我创建了一个临时的construction.html 页面,我想将所有 IP 重定向到我自己的 IP 之外。这是我的.htaccess 的样子:

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.org/$1 [R,L]

ErrorDocument 404 http://www.example.org/construction.html

Options +FollowSymlinks 
RewriteCond %{REMOTE_ADDR} !^12\.34\.567\.891
RewriteCond %{REQUEST_URI} !/construction.html$ [NC]
RewriteRule .* /construction.html [R=302,L]
  1. 奇怪的是,它最初似乎可以工作,但我的 IP大部分时间仍然被拒绝,但我还没有找到规律。有时我可以访问根 index.html,如果我明确导航到它。
  2. 更奇怪的是,如果我注释掉最后四行,我仍然会被重定向到 construction.html 页面。

我已确保清除浏览器的缓存,但这似乎没有任何作用。也许这是一个语法问题?我的理解是变化应该是即时的。

【问题讨论】:

    标签: apache .htaccess redirect mod-rewrite url-rewriting


    【解决方案1】:

    根据您显示的尝试,您能否尝试以下操作。请确保您的 index.html、consutuctions.html 和 .htaccess 规则文件存在于根文件夹中。请确保在测试您的 URL 之前清除您的浏览器缓存。

    Options +FollowSymlinks
    RewriteEngine On
    
    ##Block access to index.html here..
    RewriteRule ^index\.html/?$ - [NC,L]
    
    RewriteCond %{SERVER_PORT} 80
    RewriteRule ^(.*)/?$ https://www.example.org/$1 [NE,R=302,L]
    
    RewriteCond %{REMOTE_ADDR} !^12\.34\.567\.891
    RewriteCond %{REQUEST_URI} !/construction\.html/?$ [NC]
    RewriteRule ^ /construction.html [R=302,L]
    
    ErrorDocument 404 http://www.example.org/construction.html
    

    【讨论】:

      猜你喜欢
      • 2013-01-30
      • 1970-01-01
      • 2012-03-15
      • 2017-05-17
      • 2014-07-20
      • 1970-01-01
      • 2019-06-20
      • 2017-01-11
      • 2015-07-04
      相关资源
      最近更新 更多