0
當發佈我的Symfony
項目的新版本時,我需要使用apache將所有外部IP地址重定向到maintenance.html
頁面(該頁面居住在symfony web目錄中)。重定向到維護頁面除了一些ips
這裏是virtualhost
文件中的配置我已經爲此創建但是:
- 當我從一個外部IP去我得到
403 Forbidden
- 當我從
localhost
去我得到同樣的403 Forbidden
虛擬主機文件
<VirtualHost *:80>
ServerName myservername
ServerAlias www.myservername
ServerAdmin [email protected]
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)
mod_rewrite不知道'%{REMOTE_URI}'變量。你的意思是'%{REQUEST_URI}'? – BlueM
:'''''''(yeaaaah,那是我的錯,thx,請加上anwser,以便我接受它 – smarber