2015-02-08 12:42 GMT+09:00 Chris Arnold <carn...@electrichendrix.com>:
> >Hello. > I> have a question about 301 redirection of https. > > >My website is accessible with both of >non-subdomain http(s):// > mydomain.com and >subdomain-www http(s)://www.mydomain.com. >Both have > the same IP address. > I> would like to change https://mydomain.com/ to >redirection for > https://www.mydomain.com/. > >To change for redirecting all web contents under >mydomain.com > <http://mydomain.com/> including user directory /~user and >so on, I > tried to add the following to /etc/apache2/mods-available/ssl.conf or > /etc/apache2/sites-available/default-ssl.conf. > > ><IfModule mod_rewrite.c> > > RewriteEngine On > > RewriteCond %{HTTP_HOST} >^(mydomain\.com)(:443)? > > RewriteRule (.*) https://www.mydomain.com$1 >[R=301] > ></IfModule> > > What does your log say? I am trying to much the same but with a redirect > instead of a rewrite and found this helpful: > > http://httpd.apache.org/docs/2.4/rewrite/avoid.html > Thank you for the reply. My log access.log says only this: XXX.XXX.XXX.XX - - [08/Feb/2015:03:58:03 +0000] "HEAD / HTTP/1.1" 200 2142 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:10.0) Gecko/20100101 Firefox/10.0 (Chrome)" XXX.XXX.XXX.XX - - [08/Feb/2015:03:58:04 +0000] "GET / HTTP/1.1" 200 4104 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:10.0) Gecko/20100101 Firefox/10.0 (Chrome)" The error.log says nothing. Next, I exchanged <IfModule mod_rewrite.c> for the "Redirect". But it shows the following errors. root@hostname:~# tail -n 6 /etc/apache2/mods-available/ssl.conf <VirtualHost *:443> ServerName www.mydomain.com Redirect / https://www.mydomain.com/ </VirtualHost> # vim: syntax=apache ts=4 sw=4 sts=4 sr noet root@hostname:~# service apache2 restart * Restarting web server apache2 Action 'start' failed. The Apache error log may have more information. [fail] * The apache2 instance did not start within 20 seconds. Please read the log files to discover problems root@hostname:~# tail -n 5 /var/log/apache2/error.log [Sun Feb 08 06:12:22.767055 2015] [mpm_prefork:notice] [pid 5874] AH00169: caught SIGTERM, shutting down [Sun Feb 08 06:12:23.818133 2015] [ssl:emerg] [pid 5950] AH02240: Server should be SSL-aware but has no certificate configured [Hint: SSLCertificateFile] ((null):0) [Sun Feb 08 06:12:23.818204 2015] [ssl:emerg] [pid 5950] AH02312: Fatal error initialising mod_ssl, exiting. [Sun Feb 08 06:14:23.209329 2015] [ssl:emerg] [pid 6028] AH02240: Server should be SSL-aware but has no certificate configured [Hint: SSLCertificateFile] ((null):0) [Sun Feb 08 06:14:23.209419 2015] [ssl:emerg] [pid 6028] AH02312: Fatal error initialising mod_ssl, exiting. I think I already installed SSL certificate... Yusui