htaccess重定向-允许文件用于构建页面

问题描述 投票:1回答:2

我尝试为除我以外的所有人设置htaccess重定向。它工作正常...除了我必须为正在构造的页面想要的每个文件写一个例外。这将花费我一段时间,并且我确定有适当的方法可以做到,我只是找不到它。

我已经尝试过:

order deny,allow
deny from all
allow from 205.97.194.334
ErrorDocument 403 http://www.domain.com/page.htm

<Files page.htm>
allow from all
</Files>

但是我收到内部服务器错误

我现在所拥有的是:

RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_HOST} !^127\.0\.0\.1

RewriteCond %{REQUEST_URI} !/mypage\.html$  

RewriteRule .* http://www.domain.com/construct/mypage.html [R=302,L]

我可以添加什么以允许/ construct /中的所有内容?#

谢谢

P.S。谁能告诉我为什么第一次尝试不起作用?

编辑:

好的,我已经添加了它,它允许文件,但是,它仅在进入目录时才重定向。即domain.com将重定向到构建页面,但domain.com/index.php和其他任何内容都不会重定向

# Redirect everyone who's not from your IP
RewriteCond %{REMOTE_ADDR} !00.00.00.00 [NC]
# Allow real files to be served
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule !index.html$ http://subverb.net/construct/index.html [R=307,L]
.htaccess mod-rewrite redirect
2个回答
3
投票

如果您希望/construct其他所有人]使用,并且您希望在打开任何其他URL时将它们重定向到该URL:

# IF not from your address
RewriteCond %{REMOTE_ADDR} !^123\.4\.5\.6$

# AND not for /construct directory
RewriteCond %{REQUEST_URI} !^/construct

# THEN sen them to /construct/index.html
RewriteRule (.*) /construct/index.html [R=307,L]

0
投票

您好,我需要做相反的事情,以便在设置重定向到我的网站的地方阻止IP。这是我尝试执行的操作,但似乎无法运行:

© www.soinside.com 2019 - 2024. All rights reserved.