Apache Rewrite rules for SSL in sub domainApache Rewrite to subdomain internally onlyCpanel: Subdomain...

Python: return float 1.0 as int 1 but float 1.5 as float 1.5

Watching something be written to a file live with tail

UK: Is there precedent for the governments e-petition site changing the direction of a government decision?

Can a virus destroy the BIOS of a modern computer?

Should I tell management that I intend to leave due to bad software development practices?

What killed these X2 caps?

90's TV series where a boy goes to another dimension through portal near power lines

How to draw the figure with four pentagons?

Stopping power of mountain vs road bike

What do you call someone who asks many questions?

Infinite Abelian subgroup of infinite non Abelian group example

Do I have a twin with permutated remainders?

How much of data wrangling is a data scientist's job?

prove that the matrix A is diagonalizable

Assassin's bullet with mercury

Does a druid starting with a bow start with no arrows?

Can a rocket refuel on Mars from water?

How to model explosives?

What does it mean to describe someone as a butt steak?

Arrow those variables!

Western buddy movie with a supernatural twist where a woman turns into an eagle at the end

Is "remove commented out code" correct English?

Is Lorentz symmetry broken if SUSY is broken?

AES: Why is it a good practice to use only the first 16bytes of a hash for encryption?



Apache Rewrite rules for SSL in sub domain


Apache Rewrite to subdomain internally onlyCpanel: Subdomain redirecting to cgi-sys/defaultwebpage.cgihtaccess rewrite?multiple sub domain with multiple ssl certificate { SSL and apache }Difference b/w .htaccess and example.com.confNginx rewrite, from htaccess-filesIIS URL Rewrite - Redirect any HTTPS traffic to sub-domainApply GoDaddy signed SSL certificate to sub-domainWhere can I create or edit Nginx URL rewrite configuration file in Google App Engine?Rewrite URL after Symfony rewrites rules






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







1















I have a web site deployed that uses kohana and URL rewriting to make the URLs more restful. This works fine.



I also have Moodle installed in a sub directory on the same server and a subdomain defined for this directory. So Moodle is installed in a directory called students and the subdomain is students.example.com. This too works fine.



I am now attempting to install an SSL certificate that I only need on the sub domain. I have a Comodo wildcard certificate so it is supposed to be able to work with the subdomains. When I use https://example.com it works fine so I can see that the SSL certificate is in force. However, when I try https://students.example.com it redirects to the main site. http://students.example.com works fine though.



The .htaccess file that works for the kohana rewrite rules is:



# Use PHP5.4 Single php.ini as default
AddHandler application/x-httpd-php54s .php
# Turn on URL rewriting
RewriteEngine On

# Installation directory
RewriteBase /

# Protect hidden files from being viewed
<Files .*>
Order Deny,Allow
Deny From All
</Files>

# Protect application and system files from being viewed
RewriteRule ^(?:application|modules|system)b index.php/$0 [L]

# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php/$0 [PT]
Options -Indexes


According to the docs I will need the following rules to be added for the subdomain:



#.htaccess WildCard SSL 
RewriteCond %{HTTP_HOST} ^students.example.com$
RewriteCond %{REQUEST_URI} !^/students/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /students/$1
RewriteCond %{HTTP_HOST} ^students.example.com$
RewriteRule ^(/)?$ students/index.php [L]


I tried adding this as the first rule and as the second rule but neither worked. I now understand that I will have to write a new set of rules to do what I want.



Any advice on how to accomplish this would be greatly appreciated. This site is hosted with Bluehost if that makes any difference.










share|improve this question














bumped to the homepage by Community 3 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • What do you mean by "However, when I try students.example.com it redirects to the main site." Do you have an SSL VirtualHost for students.example.com?

    – aairey
    Oct 31 '14 at 15:16











  • I mean that it actually goes to example.com when you try to load students.example.com. However, the http version loads fine. Not sure about the SSL VirtualHost though?

    – Vincent Ramdhanie
    Oct 31 '14 at 17:03











  • you probably have a <VirtualHost default:443> somewhere. copy that and change it to <VirtualHost students.example.com:443> and put everything you would do different for this VirtualHost in there.

    – aairey
    Nov 2 '14 at 12:34


















1















I have a web site deployed that uses kohana and URL rewriting to make the URLs more restful. This works fine.



I also have Moodle installed in a sub directory on the same server and a subdomain defined for this directory. So Moodle is installed in a directory called students and the subdomain is students.example.com. This too works fine.



I am now attempting to install an SSL certificate that I only need on the sub domain. I have a Comodo wildcard certificate so it is supposed to be able to work with the subdomains. When I use https://example.com it works fine so I can see that the SSL certificate is in force. However, when I try https://students.example.com it redirects to the main site. http://students.example.com works fine though.



The .htaccess file that works for the kohana rewrite rules is:



# Use PHP5.4 Single php.ini as default
AddHandler application/x-httpd-php54s .php
# Turn on URL rewriting
RewriteEngine On

# Installation directory
RewriteBase /

# Protect hidden files from being viewed
<Files .*>
Order Deny,Allow
Deny From All
</Files>

# Protect application and system files from being viewed
RewriteRule ^(?:application|modules|system)b index.php/$0 [L]

# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php/$0 [PT]
Options -Indexes


According to the docs I will need the following rules to be added for the subdomain:



#.htaccess WildCard SSL 
RewriteCond %{HTTP_HOST} ^students.example.com$
RewriteCond %{REQUEST_URI} !^/students/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /students/$1
RewriteCond %{HTTP_HOST} ^students.example.com$
RewriteRule ^(/)?$ students/index.php [L]


I tried adding this as the first rule and as the second rule but neither worked. I now understand that I will have to write a new set of rules to do what I want.



Any advice on how to accomplish this would be greatly appreciated. This site is hosted with Bluehost if that makes any difference.










share|improve this question














bumped to the homepage by Community 3 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • What do you mean by "However, when I try students.example.com it redirects to the main site." Do you have an SSL VirtualHost for students.example.com?

    – aairey
    Oct 31 '14 at 15:16











  • I mean that it actually goes to example.com when you try to load students.example.com. However, the http version loads fine. Not sure about the SSL VirtualHost though?

    – Vincent Ramdhanie
    Oct 31 '14 at 17:03











  • you probably have a <VirtualHost default:443> somewhere. copy that and change it to <VirtualHost students.example.com:443> and put everything you would do different for this VirtualHost in there.

    – aairey
    Nov 2 '14 at 12:34














1












1








1








I have a web site deployed that uses kohana and URL rewriting to make the URLs more restful. This works fine.



I also have Moodle installed in a sub directory on the same server and a subdomain defined for this directory. So Moodle is installed in a directory called students and the subdomain is students.example.com. This too works fine.



I am now attempting to install an SSL certificate that I only need on the sub domain. I have a Comodo wildcard certificate so it is supposed to be able to work with the subdomains. When I use https://example.com it works fine so I can see that the SSL certificate is in force. However, when I try https://students.example.com it redirects to the main site. http://students.example.com works fine though.



The .htaccess file that works for the kohana rewrite rules is:



# Use PHP5.4 Single php.ini as default
AddHandler application/x-httpd-php54s .php
# Turn on URL rewriting
RewriteEngine On

# Installation directory
RewriteBase /

# Protect hidden files from being viewed
<Files .*>
Order Deny,Allow
Deny From All
</Files>

# Protect application and system files from being viewed
RewriteRule ^(?:application|modules|system)b index.php/$0 [L]

# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php/$0 [PT]
Options -Indexes


According to the docs I will need the following rules to be added for the subdomain:



#.htaccess WildCard SSL 
RewriteCond %{HTTP_HOST} ^students.example.com$
RewriteCond %{REQUEST_URI} !^/students/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /students/$1
RewriteCond %{HTTP_HOST} ^students.example.com$
RewriteRule ^(/)?$ students/index.php [L]


I tried adding this as the first rule and as the second rule but neither worked. I now understand that I will have to write a new set of rules to do what I want.



Any advice on how to accomplish this would be greatly appreciated. This site is hosted with Bluehost if that makes any difference.










share|improve this question














I have a web site deployed that uses kohana and URL rewriting to make the URLs more restful. This works fine.



I also have Moodle installed in a sub directory on the same server and a subdomain defined for this directory. So Moodle is installed in a directory called students and the subdomain is students.example.com. This too works fine.



I am now attempting to install an SSL certificate that I only need on the sub domain. I have a Comodo wildcard certificate so it is supposed to be able to work with the subdomains. When I use https://example.com it works fine so I can see that the SSL certificate is in force. However, when I try https://students.example.com it redirects to the main site. http://students.example.com works fine though.



The .htaccess file that works for the kohana rewrite rules is:



# Use PHP5.4 Single php.ini as default
AddHandler application/x-httpd-php54s .php
# Turn on URL rewriting
RewriteEngine On

# Installation directory
RewriteBase /

# Protect hidden files from being viewed
<Files .*>
Order Deny,Allow
Deny From All
</Files>

# Protect application and system files from being viewed
RewriteRule ^(?:application|modules|system)b index.php/$0 [L]

# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php/$0 [PT]
Options -Indexes


According to the docs I will need the following rules to be added for the subdomain:



#.htaccess WildCard SSL 
RewriteCond %{HTTP_HOST} ^students.example.com$
RewriteCond %{REQUEST_URI} !^/students/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /students/$1
RewriteCond %{HTTP_HOST} ^students.example.com$
RewriteRule ^(/)?$ students/index.php [L]


I tried adding this as the first rule and as the second rule but neither worked. I now understand that I will have to write a new set of rules to do what I want.



Any advice on how to accomplish this would be greatly appreciated. This site is hosted with Bluehost if that makes any difference.







apache-2.2 ssl rewrite kohana






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Oct 27 '14 at 18:47









Vincent RamdhanieVincent Ramdhanie

315




315





bumped to the homepage by Community 3 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community 3 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • What do you mean by "However, when I try students.example.com it redirects to the main site." Do you have an SSL VirtualHost for students.example.com?

    – aairey
    Oct 31 '14 at 15:16











  • I mean that it actually goes to example.com when you try to load students.example.com. However, the http version loads fine. Not sure about the SSL VirtualHost though?

    – Vincent Ramdhanie
    Oct 31 '14 at 17:03











  • you probably have a <VirtualHost default:443> somewhere. copy that and change it to <VirtualHost students.example.com:443> and put everything you would do different for this VirtualHost in there.

    – aairey
    Nov 2 '14 at 12:34



















  • What do you mean by "However, when I try students.example.com it redirects to the main site." Do you have an SSL VirtualHost for students.example.com?

    – aairey
    Oct 31 '14 at 15:16











  • I mean that it actually goes to example.com when you try to load students.example.com. However, the http version loads fine. Not sure about the SSL VirtualHost though?

    – Vincent Ramdhanie
    Oct 31 '14 at 17:03











  • you probably have a <VirtualHost default:443> somewhere. copy that and change it to <VirtualHost students.example.com:443> and put everything you would do different for this VirtualHost in there.

    – aairey
    Nov 2 '14 at 12:34

















What do you mean by "However, when I try students.example.com it redirects to the main site." Do you have an SSL VirtualHost for students.example.com?

– aairey
Oct 31 '14 at 15:16





What do you mean by "However, when I try students.example.com it redirects to the main site." Do you have an SSL VirtualHost for students.example.com?

– aairey
Oct 31 '14 at 15:16













I mean that it actually goes to example.com when you try to load students.example.com. However, the http version loads fine. Not sure about the SSL VirtualHost though?

– Vincent Ramdhanie
Oct 31 '14 at 17:03





I mean that it actually goes to example.com when you try to load students.example.com. However, the http version loads fine. Not sure about the SSL VirtualHost though?

– Vincent Ramdhanie
Oct 31 '14 at 17:03













you probably have a <VirtualHost default:443> somewhere. copy that and change it to <VirtualHost students.example.com:443> and put everything you would do different for this VirtualHost in there.

– aairey
Nov 2 '14 at 12:34





you probably have a <VirtualHost default:443> somewhere. copy that and change it to <VirtualHost students.example.com:443> and put everything you would do different for this VirtualHost in there.

– aairey
Nov 2 '14 at 12:34










3 Answers
3






active

oldest

votes


















0














I suspect you may have another issue. An HTTP request looks something like:



GET /foo.php HTTP/1.1
Host: monkedung.example.com
Keep-Alive: timeout=15
Connection: Keep-Alive


etc. When you encrypt it with SSL, everything after the GET line is encrypted, so Apache has no way of even knowing what host you are asking for. Without knowing the host, it has no way of knowing which certificate to use to decrypt the request. It also has no idea which directory to redirect to, which .htaccess file to use or anything else determined by the host. For this reason, AFAIK you can only use a single ssl host per IP address.



I would try setting



students.example.com


as the default apache domain and example.com if that is the only one that you want to use ssl for. I would also turn on debugging for your rewrite rules so you can see if they are actually firing. If the issue is the ssl issue mentioned above, I suspect you are not even getting that far.



Hope this helps.






share|improve this answer































    0














    It looks like you are trying to host example.com and students.example.com on the same IP address. This is fine if you are use regular HTTP, but if you are using HTTPS (Port 443), then you need to serve this up on a different IP address.



    <VirtualHost *:80>
    DocumentRoot /var/www/example.com
    ServerName example.com
    </VirtualHost>

    <VirtualHost *:80>
    DocumentRoot /var/www/students.example.com
    ServerName students.example.com
    </VirtualHost>

    <VirtualHost 192.168.1.10:443>
    DocumentRoot /var/www/example.com
    ServerName example.com
    SSLEngine on
    SSLCertificateFile /path/to/example.com.cert
    SSLCertificateKeyFile /path/to/example.com.key
    </VirtualHost>


    <VirtualHost 192.168.1.11:443>
    DocumentRoot /var/www/students.example.com
    ServerName students.example.com
    SSLEngine on
    SSLCertificateFile /path/to/example.com.cert
    SSLCertificateKeyFile /path/to/example.com.key
    </VirtualHost>





    share|improve this answer



















    • 1





      No you don't, all modern browsers support SNI.

      – aairey
      Nov 2 '14 at 12:32











    • Right.. SNI should work to redirect traffic to the virtual host by hostname without the need for another static IP address. Check the apache2.conf or ports.conf config file for the entry NameVirtualHost *:443 to ensure that you are resolving name-based hosts on port 443

      – Kevin Hayashi
      Nov 4 '14 at 18:35



















    0














    Have you reviewed your config.php in moodle after the SSL switch?



    Note that your $CFG->wwwroot now has changed. It should be https://students.example.com






    share|improve this answer
























      Your Answer








      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "2"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f640035%2fapache-rewrite-rules-for-ssl-in-sub-domain%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0














      I suspect you may have another issue. An HTTP request looks something like:



      GET /foo.php HTTP/1.1
      Host: monkedung.example.com
      Keep-Alive: timeout=15
      Connection: Keep-Alive


      etc. When you encrypt it with SSL, everything after the GET line is encrypted, so Apache has no way of even knowing what host you are asking for. Without knowing the host, it has no way of knowing which certificate to use to decrypt the request. It also has no idea which directory to redirect to, which .htaccess file to use or anything else determined by the host. For this reason, AFAIK you can only use a single ssl host per IP address.



      I would try setting



      students.example.com


      as the default apache domain and example.com if that is the only one that you want to use ssl for. I would also turn on debugging for your rewrite rules so you can see if they are actually firing. If the issue is the ssl issue mentioned above, I suspect you are not even getting that far.



      Hope this helps.






      share|improve this answer




























        0














        I suspect you may have another issue. An HTTP request looks something like:



        GET /foo.php HTTP/1.1
        Host: monkedung.example.com
        Keep-Alive: timeout=15
        Connection: Keep-Alive


        etc. When you encrypt it with SSL, everything after the GET line is encrypted, so Apache has no way of even knowing what host you are asking for. Without knowing the host, it has no way of knowing which certificate to use to decrypt the request. It also has no idea which directory to redirect to, which .htaccess file to use or anything else determined by the host. For this reason, AFAIK you can only use a single ssl host per IP address.



        I would try setting



        students.example.com


        as the default apache domain and example.com if that is the only one that you want to use ssl for. I would also turn on debugging for your rewrite rules so you can see if they are actually firing. If the issue is the ssl issue mentioned above, I suspect you are not even getting that far.



        Hope this helps.






        share|improve this answer


























          0












          0








          0







          I suspect you may have another issue. An HTTP request looks something like:



          GET /foo.php HTTP/1.1
          Host: monkedung.example.com
          Keep-Alive: timeout=15
          Connection: Keep-Alive


          etc. When you encrypt it with SSL, everything after the GET line is encrypted, so Apache has no way of even knowing what host you are asking for. Without knowing the host, it has no way of knowing which certificate to use to decrypt the request. It also has no idea which directory to redirect to, which .htaccess file to use or anything else determined by the host. For this reason, AFAIK you can only use a single ssl host per IP address.



          I would try setting



          students.example.com


          as the default apache domain and example.com if that is the only one that you want to use ssl for. I would also turn on debugging for your rewrite rules so you can see if they are actually firing. If the issue is the ssl issue mentioned above, I suspect you are not even getting that far.



          Hope this helps.






          share|improve this answer













          I suspect you may have another issue. An HTTP request looks something like:



          GET /foo.php HTTP/1.1
          Host: monkedung.example.com
          Keep-Alive: timeout=15
          Connection: Keep-Alive


          etc. When you encrypt it with SSL, everything after the GET line is encrypted, so Apache has no way of even knowing what host you are asking for. Without knowing the host, it has no way of knowing which certificate to use to decrypt the request. It also has no idea which directory to redirect to, which .htaccess file to use or anything else determined by the host. For this reason, AFAIK you can only use a single ssl host per IP address.



          I would try setting



          students.example.com


          as the default apache domain and example.com if that is the only one that you want to use ssl for. I would also turn on debugging for your rewrite rules so you can see if they are actually firing. If the issue is the ssl issue mentioned above, I suspect you are not even getting that far.



          Hope this helps.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 1 '14 at 13:21









          jpgeekjpgeek

          28113




          28113

























              0














              It looks like you are trying to host example.com and students.example.com on the same IP address. This is fine if you are use regular HTTP, but if you are using HTTPS (Port 443), then you need to serve this up on a different IP address.



              <VirtualHost *:80>
              DocumentRoot /var/www/example.com
              ServerName example.com
              </VirtualHost>

              <VirtualHost *:80>
              DocumentRoot /var/www/students.example.com
              ServerName students.example.com
              </VirtualHost>

              <VirtualHost 192.168.1.10:443>
              DocumentRoot /var/www/example.com
              ServerName example.com
              SSLEngine on
              SSLCertificateFile /path/to/example.com.cert
              SSLCertificateKeyFile /path/to/example.com.key
              </VirtualHost>


              <VirtualHost 192.168.1.11:443>
              DocumentRoot /var/www/students.example.com
              ServerName students.example.com
              SSLEngine on
              SSLCertificateFile /path/to/example.com.cert
              SSLCertificateKeyFile /path/to/example.com.key
              </VirtualHost>





              share|improve this answer



















              • 1





                No you don't, all modern browsers support SNI.

                – aairey
                Nov 2 '14 at 12:32











              • Right.. SNI should work to redirect traffic to the virtual host by hostname without the need for another static IP address. Check the apache2.conf or ports.conf config file for the entry NameVirtualHost *:443 to ensure that you are resolving name-based hosts on port 443

                – Kevin Hayashi
                Nov 4 '14 at 18:35
















              0














              It looks like you are trying to host example.com and students.example.com on the same IP address. This is fine if you are use regular HTTP, but if you are using HTTPS (Port 443), then you need to serve this up on a different IP address.



              <VirtualHost *:80>
              DocumentRoot /var/www/example.com
              ServerName example.com
              </VirtualHost>

              <VirtualHost *:80>
              DocumentRoot /var/www/students.example.com
              ServerName students.example.com
              </VirtualHost>

              <VirtualHost 192.168.1.10:443>
              DocumentRoot /var/www/example.com
              ServerName example.com
              SSLEngine on
              SSLCertificateFile /path/to/example.com.cert
              SSLCertificateKeyFile /path/to/example.com.key
              </VirtualHost>


              <VirtualHost 192.168.1.11:443>
              DocumentRoot /var/www/students.example.com
              ServerName students.example.com
              SSLEngine on
              SSLCertificateFile /path/to/example.com.cert
              SSLCertificateKeyFile /path/to/example.com.key
              </VirtualHost>





              share|improve this answer



















              • 1





                No you don't, all modern browsers support SNI.

                – aairey
                Nov 2 '14 at 12:32











              • Right.. SNI should work to redirect traffic to the virtual host by hostname without the need for another static IP address. Check the apache2.conf or ports.conf config file for the entry NameVirtualHost *:443 to ensure that you are resolving name-based hosts on port 443

                – Kevin Hayashi
                Nov 4 '14 at 18:35














              0












              0








              0







              It looks like you are trying to host example.com and students.example.com on the same IP address. This is fine if you are use regular HTTP, but if you are using HTTPS (Port 443), then you need to serve this up on a different IP address.



              <VirtualHost *:80>
              DocumentRoot /var/www/example.com
              ServerName example.com
              </VirtualHost>

              <VirtualHost *:80>
              DocumentRoot /var/www/students.example.com
              ServerName students.example.com
              </VirtualHost>

              <VirtualHost 192.168.1.10:443>
              DocumentRoot /var/www/example.com
              ServerName example.com
              SSLEngine on
              SSLCertificateFile /path/to/example.com.cert
              SSLCertificateKeyFile /path/to/example.com.key
              </VirtualHost>


              <VirtualHost 192.168.1.11:443>
              DocumentRoot /var/www/students.example.com
              ServerName students.example.com
              SSLEngine on
              SSLCertificateFile /path/to/example.com.cert
              SSLCertificateKeyFile /path/to/example.com.key
              </VirtualHost>





              share|improve this answer













              It looks like you are trying to host example.com and students.example.com on the same IP address. This is fine if you are use regular HTTP, but if you are using HTTPS (Port 443), then you need to serve this up on a different IP address.



              <VirtualHost *:80>
              DocumentRoot /var/www/example.com
              ServerName example.com
              </VirtualHost>

              <VirtualHost *:80>
              DocumentRoot /var/www/students.example.com
              ServerName students.example.com
              </VirtualHost>

              <VirtualHost 192.168.1.10:443>
              DocumentRoot /var/www/example.com
              ServerName example.com
              SSLEngine on
              SSLCertificateFile /path/to/example.com.cert
              SSLCertificateKeyFile /path/to/example.com.key
              </VirtualHost>


              <VirtualHost 192.168.1.11:443>
              DocumentRoot /var/www/students.example.com
              ServerName students.example.com
              SSLEngine on
              SSLCertificateFile /path/to/example.com.cert
              SSLCertificateKeyFile /path/to/example.com.key
              </VirtualHost>






              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered Nov 1 '14 at 23:35









              Kevin HayashiKevin Hayashi

              1463




              1463








              • 1





                No you don't, all modern browsers support SNI.

                – aairey
                Nov 2 '14 at 12:32











              • Right.. SNI should work to redirect traffic to the virtual host by hostname without the need for another static IP address. Check the apache2.conf or ports.conf config file for the entry NameVirtualHost *:443 to ensure that you are resolving name-based hosts on port 443

                – Kevin Hayashi
                Nov 4 '14 at 18:35














              • 1





                No you don't, all modern browsers support SNI.

                – aairey
                Nov 2 '14 at 12:32











              • Right.. SNI should work to redirect traffic to the virtual host by hostname without the need for another static IP address. Check the apache2.conf or ports.conf config file for the entry NameVirtualHost *:443 to ensure that you are resolving name-based hosts on port 443

                – Kevin Hayashi
                Nov 4 '14 at 18:35








              1




              1





              No you don't, all modern browsers support SNI.

              – aairey
              Nov 2 '14 at 12:32





              No you don't, all modern browsers support SNI.

              – aairey
              Nov 2 '14 at 12:32













              Right.. SNI should work to redirect traffic to the virtual host by hostname without the need for another static IP address. Check the apache2.conf or ports.conf config file for the entry NameVirtualHost *:443 to ensure that you are resolving name-based hosts on port 443

              – Kevin Hayashi
              Nov 4 '14 at 18:35





              Right.. SNI should work to redirect traffic to the virtual host by hostname without the need for another static IP address. Check the apache2.conf or ports.conf config file for the entry NameVirtualHost *:443 to ensure that you are resolving name-based hosts on port 443

              – Kevin Hayashi
              Nov 4 '14 at 18:35











              0














              Have you reviewed your config.php in moodle after the SSL switch?



              Note that your $CFG->wwwroot now has changed. It should be https://students.example.com






              share|improve this answer




























                0














                Have you reviewed your config.php in moodle after the SSL switch?



                Note that your $CFG->wwwroot now has changed. It should be https://students.example.com






                share|improve this answer


























                  0












                  0








                  0







                  Have you reviewed your config.php in moodle after the SSL switch?



                  Note that your $CFG->wwwroot now has changed. It should be https://students.example.com






                  share|improve this answer













                  Have you reviewed your config.php in moodle after the SSL switch?



                  Note that your $CFG->wwwroot now has changed. It should be https://students.example.com







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 6 '14 at 7:35









                  infrclinfrcl

                  1011




                  1011






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Server Fault!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f640035%2fapache-rewrite-rules-for-ssl-in-sub-domain%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Фонтен-ла-Гаярд Зміст Демографія | Економіка | Посилання |...

                      Список ссавців Італії Природоохоронні статуси | Список |...

                      Маріан Котлеба Зміст Життєпис | Політичні погляди |...