Hi,
There is any way to force a url to ssl, for eg, if we type http://www.domain.com/customer itīs go to https://www.domain.com/customer ?
regards,
winger.![]()
This is a discussion on Ssl in the VPS & Dedicated forum
Hi,
There is any way to force a url to ssl, for eg, if we type http://www.domain.com/customer itīs go to https://www.domain.com/customer ?
regards,
winger. ...
Hi,
There is any way to force a url to ssl, for eg, if we type http://www.domain.com/customer itīs go to https://www.domain.com/customer ?
regards,
winger.![]()
WebHostingTalk now in portuguese
www.webhostingtalk.com.br venha se juntar a nossa comunidade sobre hospedagem web
Hi Winger,
That's certainly possible, I personally always use that on order forms and such.
It's also possible to do this in a .htaccess file but I prefer to edit things directly in the httpd.conf.
First login to your VPS with SSH (as root). Then open /usr/local/apache/conf/httpd.conf (or whereever your httpd.conf is stored). Now scroll down to the VirtualHost entry of the domain you want this to take effect on. At the end of that VirtualHost entry, insert this:
Code:RewriteEngine on RewriteCond %{SERVER_PORT} =80 RewriteRule ^(.*) https://%{SERVER_NAME}%{REQUEST_URI}
So for instance:
Would become:Code:<VirtualHost 1.2.3.4> BytesLog domlogs/secure.domain.com-bytes_log ServerName secure.domain.com ServerAlias secure.domain.com ServerAdmin wwwadmin@domain.com DocumentRoot /home/domain/public_html/secure CustomLog domlogs/secure.domain.com combined ScriptAlias /cgi-bin/ /home/domain/public_html/secure/cgi-bin/ User sh Group sh </VirtualHost> <IfDefine SSL> <VirtualHost 1.2.3.4:443> ServerAdmin webmaster@secure.domain.com DocumentRoot /home/domain/public_html/secure BytesLog domlogs/secure.domain.com-bytes_log ServerName secure.domain.com CustomLog /usr/local/apache/domlogs/secure.domain.com-ssl_log "%t %{version}c %{cipher}c %{clientcert}c" User domain Group domain SSLEnable SSLCertificateFile /usr/share/ssl/certs/secure.domain.com.crt SSLCertificateKeyFile /usr/share/ssl/private/secure.domain.com.key SSLCACertificateFile /usr/share/ssl/certs/secure.domain.com.cabundle SSLLogFile /var/log/secure.domain.com UserDir public_html/secure ScriptAlias /cgi-bin/ /home/domain/public_html/secure/cgi-bin/ SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown </VirtualHost> </IfDefine>
Note 1: You have to make sure to insert these 3 lines in the http (port 80) part of the VirtualHost as I've shown above. If you would insert those 3 lines in the https part of the VirtualHost you would cause an infinite loop.Code:<VirtualHost 1.2.3.4> BytesLog domlogs/secure.domain.com-bytes_log ServerName secure.domain.com ServerAlias secure.domain.com ServerAdmin wwwadmin@domain.com DocumentRoot /home/domain/public_html/secure CustomLog domlogs/secure.domain.com combined ScriptAlias /cgi-bin/ /home/domain/public_html/secure/cgi-bin/ User sh Group sh RewriteEngine on RewriteCond %{SERVER_PORT} =80 RewriteRule ^(.*) https://%{SERVER_NAME}%{REQUEST_URI} </VirtualHost> <IfDefine SSL> <VirtualHost 1.2.3.4:443> ServerAdmin webmaster@secure.domain.com DocumentRoot /home/domain/public_html/secure BytesLog domlogs/secure.domain.com-bytes_log ServerName secure.domain.com CustomLog /usr/local/apache/domlogs/secure.domain.com-ssl_log "%t %{version}c %{cipher}c %{clientcert}c" User domain Group domain SSLEnable SSLCertificateFile /usr/share/ssl/certs/secure.domain.com.crt SSLCertificateKeyFile /usr/share/ssl/private/secure.domain.com.key SSLCACertificateFile /usr/share/ssl/certs/secure.domain.com.cabundle SSLLogFile /var/log/secure.domain.com UserDir public_html/secure ScriptAlias /cgi-bin/ /home/domain/public_html/secure/cgi-bin/ SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown </VirtualHost> </IfDefine>
Note 2: You have to make sure that your Apache is compiled with mod_rewrite. On cPanel servers that's usually enabled by default
Andre van Vliet
DEHE.com - Definition of Hosting Experts
Hi Andre,
Thank you very much!
regards,
winger.
WebHostingTalk now in portuguese
www.webhostingtalk.com.br venha se juntar a nossa comunidade sobre hospedagem web
Andre,
I must change SERVER_NAME with the domain and REQUEST_URI with the folder name?
RewriteEngine on
RewriteCond %{SERVER_PORT} =80
RewriteRule ^(.*) https://%{SERVER_NAME}%{REQUEST_URI}
Winger.
WebHostingTalk now in portuguese
www.webhostingtalk.com.br venha se juntar a nossa comunidade sobre hospedagem web
You're welcome.
No you should leave it all the way it is, don't change anything in it.
Andre van Vliet
DEHE.com - Definition of Hosting Experts
Copyright © 2011 JaguarPC.com
Bookmarks