小编Bra*_*hde的帖子

在.htaccess中使用基于环境变量的RewriteCond

我试图在我的.htaccess文件中定义一个环境变量,然后使用该变量运行重写条件.以下是我的.htaccess文件中的内容,但重写不起作用:

RewriteEngine on
#set to 'live' or 'maintenance'
SetEnv ENVIRONMENT maintenance

#If the ENVIRONMENT variable is 'mainetnance' then show a maintenance page to the users
RewriteCond %{ENV:ENVIRONMENT} maintenance
RewriteRule ^(.*)$ /maintenance.html
Run Code Online (Sandbox Code Playgroud)

这样做的目的是通过让PHP编辑.htaccess文件来编程,将网站设置为维护模式,当它从GitHub的一个钩子接收到一个post请求时,可以获取更新的repo.

apache .htaccess mod-rewrite

11
推荐指数
3
解决办法
2万
查看次数

标签 统计

.htaccess ×1

apache ×1

mod-rewrite ×1