我是Apachenetworking服务器的新手,所以我可能会做一些明显的错误。
我通过Debian软件包pipe理器安装了“OwnCloud”,默认情况下也安装了Apache Web服务器。 基本的安装工程确定,我可以使用OwnCloud罚款。
我现在想要启用https连接,并将所有http请求redirect到https,但是我无法使redirect工作。 在试图理解和解决问题的同时,Apache似乎也忽略了对configuration文件的更改,例如更改默认VirtualHost的DocumentRoot没有任何作用。
因为这是一个Debian安装,我知道configuration文件与标准Apache安装位置稍有不同。
在sites-available目录中,我有以下几点:
<VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www/test # ServerName <removed_for_privacy> # Redirect permanent / https://<removed_for_privacy> ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined Redirect / https://<removed_for_privacy>/owncloud </VirtualHost> <VirtualHost <removed_for_privacy>:80> ServerName <removed_for_privacy> Redirect permanent /owncloud https://<removed_for_privacy>/owncloud ErrorLog ${APACHE_LOG_DIR}/error.log </VirtualHost>
在上面我用<removed_for_privacy>replace了服务器名称
我也在同一个目录中创build了一个特定的owncloud-ssl.conf文件,试图使它工作:
<IfModule mod_ssl.c> <VirtualHost <removed_for_privacy>:443> ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined # SSL Engine Switch: # Enable/Disable SSL for this virtual host. SSLEngine on SSLCertificateFile /etc/ssl/certs/<removed_for_privacy>.pem SSLCertificateKeyFile /etc/ssl/certs/<removed_for_privacy>.key </VirtualHost>
如果我手动键入它的工作正常,但我想redirecthttp请求到https,但redirect永远不会发生。
也只是出于实验,我试图将DocumentRoot更改为标准/var/www子目录,但重新启动Apache后,仍然在/var/www而不是其中的子目录。
任何帮助赞赏。
更新
我已经尝试删除000-default.conf和怪异的apache继续响应http请求! 当然,这个文件删除它应该抱怨/摔倒? 我不知道它是如何configuration的
如果使用mod_rewrite选项,则将以下configuration添加到.htaccess文件中:
RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
确保在httpd.conf(mod_rewrite支持)中有如下的内容:
LoadModule rewrite_module modules/mod_rewrite.so