【发布时间】:2023-03-21 00:55:01
【问题描述】:
我正在尝试在我的 .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
这样做的目的是通过让 PHP 在收到来自 GitHub 挂钩之一的发布请求以拉取 repo 进行更新时,以编程方式将站点设置为维护模式。
【问题讨论】:
标签: apache .htaccess mod-rewrite