在发布我的Symfony
项目的新版本时,我需要使用apache将所有外部IP地址重定向到maintenance.html
页面(它位于symfony web目录中)。
以下是我为此目的创建的virtualhost
文件配置,但是:
403 Forbidden
localhost
出发时,我得到同样的403 Forbidden
虚拟主机文件
<VirtualHost *:80>
ServerName myservername
ServerAlias www.myservername
ServerAdmin webmaster@localhost
DocumentRoot /path/to/my/symfony/project/web
RewriteEngine on
# if request not coming from localhost
RewriteCond %{REMOTE_ADDR} !127.0.0.1
# if request not maintenance.html page
RewriteCond %{REMOTE_URI} !/maintenance.html [NC]
# if request not image
RewriteCond %{REMOTE_URI} !\.(jpe?g?|png|gif|ico) [NC]
# if request not css file
RewriteCond %{REMOTE_URI} !\.(css) [NC]
# Redirect to maintenance.html page
RewriteRule .* /maintenance.html [R=302,L]
<Directory /path/to/my/symfony/project/web>
# Ignore .htaccess files
AllowOverride None
</Directory>
ErrorLog ${APACHE_LOG_DIR}/maintenance-error.log
CustomLog ${APACHE_LOG_DIR}/maintenance-access.log combined
</VirtualHost>
我做错了什么?
技术版
apache2 -v 2.4.7 (needs to work on 2.2 too)
答案 0 :(得分:1)
mod_rewrite不知道%{REMOTE_URI}
变量。可能你的意思是%{REQUEST_URI}
。