Kategori arşivi: Htaccess

ubuntu 14 apache ssl activate, create self signed certificate, configure virtual host

sudo a2enmod ssl
sudo service apache2 restart
sudo mkdir /etc/apache2/ssl
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/apache2/ssl/your_domain.key -out /etc/apache2/ssl/your_domain.crt
Country Name (2 letter code) [AU]:US
State or Province Name (full name) [Some-State]:New York
Locality Name (eg, city) []:New York City
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Your Company
Organizational Unit Name (eg, section) []:Department of Kittens
Common Name (e.g. server FQDN or YOUR name) []:your_domain.com
Email Address []:your_email@domain.com
sudo nano /etc/apache2/sites-available/default-ssl.conf
<IfModule mod_ssl.c>
  <VirtualHost _default_:443>
       		....
  </VirtualHost>

  <VirtualHost _default_:443>
	ServerName www.your_domain.com
	ServerAlias your_domain.com
	DocumentRoot /var/www/your_domain.com
		
	ErrorLog ${APACHE_LOG_DIR}/error_your_domain_com_ssl.log
	CustomLog ${APACHE_LOG_DIR}/access_your_domain_ssl.log common	
			
	SSLEngine on
	SSLCertificateFile /etc/apache2/ssl/apache.crt
        SSLCertificateKeyFile /etc/apache2/ssl/apache.key
  </VirtualHost>
</IfModule>
sudo a2ensite default-ssl.conf
sudo service apache2 restart
RewriteEngine on

RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]

RewriteCond %{HTTPS} !on
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# If a directory or a file exists, use the request directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward the request to index.php
RewriteRule . index.php
https://your_domain.com