安裝完了 letscrypt 後,當然要讓自己的網站都強制使用 https 較安全的連線囉!
- 首先要先開啟 rewrite module
sudo a2enmod rewrite - 打開 /etc/apache2/apache2.conf ,加入以下程式碼
<Directory /var/www/> Options Indexes FollowSymLinks AllowOverride All Require all granted RewriteEngine on RewriteCond %{SERVER_PORT} !^443$ RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R] </Directory>
- 若為 wordpress ,則要進入wordpress 目錄後複寫 .htaccess
# BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] RewriteCond %{SERVER_PORT} !^443$ RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R] </IfModule> # END WordPress
- 重新啟動 apache
sudo service apache2 restart - 完成囉!
參考資料:
http://blog.changyy.org/2013/02/apache-web-server-https-ubuntu-1204.html
Leave a Reply