Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.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
Apache.htaccess重写cond以排除维护文件和zend backoffice_Apache_.htaccess_Zend Framework_Mod Rewrite - Fatal编程技术网

Apache.htaccess重写cond以排除维护文件和zend backoffice

Apache.htaccess重写cond以排除维护文件和zend backoffice,apache,.htaccess,zend-framework,mod-rewrite,Apache,.htaccess,Zend Framework,Mod Rewrite,在大数据导入期间,我必须对网站进行维护。 导入是在后台完成的,所以我需要对前台进行维护,而不是后台 在my.htaccess中有适用于所有人的url,但我需要排除所有以/admin(.*)开头的url: 我尝试了不同的方法,但第一次重写时,这些方法并不奏效: RewriteCond %{REQUEST_URI} !^/(admin(.*)|maintenance.php) 或者: RewriteCond %{REQUEST_FILENAME} !/maintenance.php$ Rewrit

在大数据导入期间,我必须对网站进行维护。 导入是在后台完成的,所以我需要对前台进行维护,而不是后台

在my.htaccess中有适用于所有人的url,但我需要排除所有以/admin(.*)开头的url:

我尝试了不同的方法,但第一次重写时,这些方法并不奏效:

RewriteCond %{REQUEST_URI} !^/(admin(.*)|maintenance.php)
或者:

RewriteCond %{REQUEST_FILENAME} !/maintenance.php$
RewriteCond %{REQUEST_URI} !/admin(.*)$

感谢您的帮助

我确信可以用.htaccess完成,但您可以尝试使用控制器插件的另一个选项。
您可以将逻辑放入dispatchLoopStartup()钩子中,如果是对frontoffice的请求,则将用户重定向到maintenance.php,否则什么也不做。

无需重写Cond只是一个好的重写规则:

# Maintenance things
RewriteRule !^(admin(.*)|index.php|maintenance.php)$ /maintenance.php [R=302,L]

# Standard zend framework rewrite rules :
RewriteRule .* - [env=not_alias:true]
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{ENV:not_alias} !=true
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

我需要在.htaccess中这样做,以便在数据导入期间不必使用Zend/Php和MySQL访问的内存。
# Maintenance things
RewriteRule !^(admin(.*)|index.php|maintenance.php)$ /maintenance.php [R=302,L]

# Standard zend framework rewrite rules :
RewriteRule .* - [env=not_alias:true]
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{ENV:not_alias} !=true
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]