Welcome to the JaguarPC Community
JaguarPC
Sales: (888) 338-5261
Support: (888)-551-3050
Results 1 to 5 of 5

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. ...

  1. #1
    JPC Addict winger's Avatar
    Join Date
    Nov 2006
    Location
    Rio de Janeiro - BR
    Posts
    135

    Ssl

    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

  2. #2
    consultant Andre's Avatar
    Join Date
    Apr 2005
    Posts
    1,155
    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:

    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>
    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
    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 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.

    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

  3. #3
    JPC Addict winger's Avatar
    Join Date
    Nov 2006
    Location
    Rio de Janeiro - BR
    Posts
    135
    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

  4. #4
    JPC Addict winger's Avatar
    Join Date
    Nov 2006
    Location
    Rio de Janeiro - BR
    Posts
    135

    Ops

    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

  5. #5
    consultant Andre's Avatar
    Join Date
    Apr 2005
    Posts
    1,155
    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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •