Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess htaccess重定向-允许文件用于构造页面_.htaccess_Mod Rewrite_Redirect - Fatal编程技术网

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

.htaccess htaccess重定向-允许文件用于构造页面,.htaccess,mod-rewrite,redirect,.htaccess,Mod Rewrite,Redirect,我已尝试为除我之外的所有人设置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 </

我已尝试为除我之外的所有人设置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>
我可以添加什么来允许/construct/中的所有内容#

谢谢

有人能告诉我第一次尝试失败的原因吗

编辑:

好的,我已经添加了这个,它允许文件,但是,它只是在输入目录时重定向。也就是说,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]

如果希望
/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]

请准确地定义(例如,以列表的形式)您希望为您的站点提供哪些规则。你想让每个人都能访问除/construct之外的所有内容吗?它只能从允许的IP访问。对不起,虽然它正在建设中,但我想成为唯一一个可以访问该网站的人,所以我允许我的IP。但是我需要构建页面正在使用的所有文件(位于构建目录中)。目前它正在工作,但仅在进入主域时重定向。它的任何扩展,甚至domain.com/index.php都不会重定向。重定向应该是将除我之外的所有人发送到construct/index.htmlh。这仍然使我处于相同的位置,重定向仅在成员转到主目录(即domain.com)时才起作用。如果它们转到目录中的任何其他地方,甚至仅仅是domain.com/index.php,或者任何子目录,重定向都不起作用。我想阻止所有人,除了me@Michael马利特,你试过了吗?在您的示例中,
domain.com/index.php
条件
^/construct
将为真,
(.*)
也将为真,因此重定向将发生。啊,aplogies,我仍然需要重写cond%{REQUEST\u FILENAME}-f在我刚刚移除的地方。谢谢,这很好用
# 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]