ubuntu18,apache2
域名:http://www.xxx.com,ports.conf已添加Listen 88和Listen 888,nextcloudssl.conf已修改好,鏈接https://www.xxx.com:888可以正常使用,但鏈接http://www.xxx.com:88重定向到https://www.xxx.com,如何修改nextcloud.conf才能重定向到https://www.xxx.com:888。
------------------------------------------------------------
nextcloud.conf代碼如下:
<VirtualHost *:88>
ServerAdmin [email protected]
DocumentRoot /var/www/nextcloud/
ServerName xxx.com
ServerAlias www.xxx.com
<Directory /var/www/nextcloud/>
Options +FollowSymlinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =xxx.com [OR]
RewriteCond %{SERVER_NAME} =www.xxx.com
RewriteCond %{SERVER_PORT} !^888$
RewriteRule ^ https://%{SERVER_NAME}:888%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
------------------------------------------
nextcloudssl.conf代碼如下:
<IfModule mod_ssl.c>
<VirtualHost *:888>
ServerAdmin [email protected]
ServerName www.xxx.com
DocumentRoot /var/www/nextcloud
<Directory /var/www/nextcloud/>
Options +FollowSymlinks
AllowOverride All
<IfModule mod_dav.c>
Dav off
</IfModule>
SetEnv HOME /var/www/nextcloud
SetEnv HTTP_HOME /var/www/nextcloud
</Directory>
<IfModule mod_headers.c>
Header always set Strict-Transport-Security "max-age=15768000; preload"
</IfModule>
SSLEngine on
SSLCertificateFile /etc/apache2/cert/xxx.public.crt
SSLCertificateKeyFile /etc/apache2/cert/xxx.key
SSLCertificateChainFile /etc/apache2/cert/xxx.chain.crt
</VirtualHost>
</IfModule>
uj5u.com熱心網友回復:
頂起來呀。。。。。uj5u.com熱心網友回復:
網頁根目錄下面新建一個.htaccess檔案,把下面的代碼放進去就可以了RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
以上代碼意思為http來路跳轉到https,前提是你的http和https設定都沒有問題就可以。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/89840.html
標籤:Apache
