我正在编写一个虚拟主机,以允许加密通过http和其他任何请求到https的请求访问文件
这是我的完整vhost配置
<VirtualHost *:80>
ServerAdmin admin@{{ domain_name }}
ServerName {{ domain_name }}
ServerAlias {{ domain_name }}
DocumentRoot /var/www/letsencrypt
<Directory /var/www/letsencrypt>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond ^/.well-known/acme-challenge$ [NC]
RewriteRule (.*) https://%{SERVER_NAME}/$1 [R,L]
</IfModule>
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
当我评论我的RewriteCond时,我重定向到了https,但是我无法使我的RewriteCond工作。
答案 0 :(得分:0)
我的vhost conf包含两个错误,一个错误在RewriteCond
上,一个错误在conf中重写的位置。
在这里起作用:
<VirtualHost *:80>
ServerAdmin admin@{{ domain_name }}
ServerName {{ domain_name }}
ServerAlias {{ domain_name }}
DocumentRoot /var/www/letsencrypt
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/.well-known/acme-challenge [NC]
RewriteRule (.*) https://%{SERVER_NAME}/$1 [R,L]
</IfModule>
<Directory /var/www/letsencrypt>
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error-http-{{ domain_name }}.log
CustomLog ${APACHE_LOG_DIR}/access-http-{{ domain_name }}.log combined
</VirtualHost>