Apache allowing HTTPS inside Virtual Hosts .crf file












0















I am setting up an UBUNTU 18.04 enviroment with apache, mysql, phpmyadmin etc etc.



I need to allow HTTPS access for URL rewrites, currently HTTPS crash when i enter a URL which has been rewritten in .htaccess



HTTPS:



If i acces through HTTPS, only https://www.mysite.com works, if i try to access https://mysite.com/content/1 the website crash but if i try to access https://www.mysite.com?page=content&id=1 everything works and there is a HTTPS connection



HTTP:



If i access through HTTP there is no problems i can access all domains e.g http://mysite.com/user and http://mysite.com/content/1



I found different tutorials and guides and i've come to the conclusion that i need to edit the Virtusl Hosts .cfg file



<VirtualHost *:443>
ServerName <myip>
DocumentRoot /var/www/html
SSLEngine on
SSLCertificateFile /etc/ssl/certs/apache-selfsigned.crt
SSLCertificateKeyFile /etc/ssl/private/apache-selfsigned.key
<Directory /var/www/html>
DirectoryIndex index.php
AllowOverride All
Require all granted
</Directory>
</VirtualHost>


I need think that i need to get these 2 parts



SSLCertificateFile      /etc/ssl/certs/apache-selfsigned.crt
SSLCertificateKeyFile /etc/ssl/private/apache-selfsigned.key


Where do i get these .crt and .key files?
Do they have anything to do with SSL private/public keys? because these two files i have, but they do not have .crt and .key extensions HTTPS is however is enabled.



Whole Config File



<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com

ServerAdmin webmaster@localhost
ServerName whattodoonline.com
ServerAlias www.whattodoonline.com
# Redirect permanent / https://www.mysite.com/
DocumentRoot /var/www/html

<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>


# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf

</VirtualHost>

<VirtualHost *:443>
ServerName <myip>
DocumentRoot /var/www/html
SSLEngine on
SSLCertificateFile /etc/ssl/certs/apache-selfsigned.crt
SSLCertificateKeyFile /etc/ssl/private/apache-selfsigned.key
<Directory /var/www/html>
DirectoryIndex index.php
AllowOverride All
Require all granted
</Directory>
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet


.htaccess file



RewriteEngine On 

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)/([^/]+)$ index.php?page=$1&c=$2&d=$3&e=$4 [NC,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)/([^/]+)$ index.php?page=$1&c=$2&d=$3 [NC,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)$ index.php?page=$1&c=$2 [NC,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)$ index.php?page=$1 [NC,L]









share|improve this question







New contributor




ii iml0sto1 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

























    0















    I am setting up an UBUNTU 18.04 enviroment with apache, mysql, phpmyadmin etc etc.



    I need to allow HTTPS access for URL rewrites, currently HTTPS crash when i enter a URL which has been rewritten in .htaccess



    HTTPS:



    If i acces through HTTPS, only https://www.mysite.com works, if i try to access https://mysite.com/content/1 the website crash but if i try to access https://www.mysite.com?page=content&id=1 everything works and there is a HTTPS connection



    HTTP:



    If i access through HTTP there is no problems i can access all domains e.g http://mysite.com/user and http://mysite.com/content/1



    I found different tutorials and guides and i've come to the conclusion that i need to edit the Virtusl Hosts .cfg file



    <VirtualHost *:443>
    ServerName <myip>
    DocumentRoot /var/www/html
    SSLEngine on
    SSLCertificateFile /etc/ssl/certs/apache-selfsigned.crt
    SSLCertificateKeyFile /etc/ssl/private/apache-selfsigned.key
    <Directory /var/www/html>
    DirectoryIndex index.php
    AllowOverride All
    Require all granted
    </Directory>
    </VirtualHost>


    I need think that i need to get these 2 parts



    SSLCertificateFile      /etc/ssl/certs/apache-selfsigned.crt
    SSLCertificateKeyFile /etc/ssl/private/apache-selfsigned.key


    Where do i get these .crt and .key files?
    Do they have anything to do with SSL private/public keys? because these two files i have, but they do not have .crt and .key extensions HTTPS is however is enabled.



    Whole Config File



    <VirtualHost *:80>
    # The ServerName directive sets the request scheme, hostname and port that
    # the server uses to identify itself. This is used when creating
    # redirection URLs. In the context of virtual hosts, the ServerName
    # specifies what hostname must appear in the request's Host: header to
    # match this virtual host. For the default virtual host (this file) this
    # value is not decisive as it is used as a last resort host regardless.
    # However, you must set it for any further virtual host explicitly.
    #ServerName www.example.com

    ServerAdmin webmaster@localhost
    ServerName whattodoonline.com
    ServerAlias www.whattodoonline.com
    # Redirect permanent / https://www.mysite.com/
    DocumentRoot /var/www/html

    <Directory /var/www/html>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Require all granted
    </Directory>


    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
    # error, crit, alert, emerg.
    # It is also possible to configure the loglevel for particular
    # modules, e.g.
    #LogLevel info ssl:warn

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    # For most configuration files from conf-available/, which are
    # enabled or disabled at a global level, it is possible to
    # include a line for only one particular virtual host. For example the
    # following line enables the CGI configuration for this host only
    # after it has been globally disabled with "a2disconf".
    #Include conf-available/serve-cgi-bin.conf

    </VirtualHost>

    <VirtualHost *:443>
    ServerName <myip>
    DocumentRoot /var/www/html
    SSLEngine on
    SSLCertificateFile /etc/ssl/certs/apache-selfsigned.crt
    SSLCertificateKeyFile /etc/ssl/private/apache-selfsigned.key
    <Directory /var/www/html>
    DirectoryIndex index.php
    AllowOverride All
    Require all granted
    </Directory>
    </VirtualHost>

    # vim: syntax=apache ts=4 sw=4 sts=4 sr noet


    .htaccess file



    RewriteEngine On 

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([^/]+)/([^/]+)/([^/]+)$ index.php?page=$1&c=$2&d=$3&e=$4 [NC,L]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([^/]+)/([^/]+)/([^/]+)$ index.php?page=$1&c=$2&d=$3 [NC,L]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([^/]+)/([^/]+)$ index.php?page=$1&c=$2 [NC,L]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([^/]+)$ index.php?page=$1 [NC,L]









    share|improve this question







    New contributor




    ii iml0sto1 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.























      0












      0








      0








      I am setting up an UBUNTU 18.04 enviroment with apache, mysql, phpmyadmin etc etc.



      I need to allow HTTPS access for URL rewrites, currently HTTPS crash when i enter a URL which has been rewritten in .htaccess



      HTTPS:



      If i acces through HTTPS, only https://www.mysite.com works, if i try to access https://mysite.com/content/1 the website crash but if i try to access https://www.mysite.com?page=content&id=1 everything works and there is a HTTPS connection



      HTTP:



      If i access through HTTP there is no problems i can access all domains e.g http://mysite.com/user and http://mysite.com/content/1



      I found different tutorials and guides and i've come to the conclusion that i need to edit the Virtusl Hosts .cfg file



      <VirtualHost *:443>
      ServerName <myip>
      DocumentRoot /var/www/html
      SSLEngine on
      SSLCertificateFile /etc/ssl/certs/apache-selfsigned.crt
      SSLCertificateKeyFile /etc/ssl/private/apache-selfsigned.key
      <Directory /var/www/html>
      DirectoryIndex index.php
      AllowOverride All
      Require all granted
      </Directory>
      </VirtualHost>


      I need think that i need to get these 2 parts



      SSLCertificateFile      /etc/ssl/certs/apache-selfsigned.crt
      SSLCertificateKeyFile /etc/ssl/private/apache-selfsigned.key


      Where do i get these .crt and .key files?
      Do they have anything to do with SSL private/public keys? because these two files i have, but they do not have .crt and .key extensions HTTPS is however is enabled.



      Whole Config File



      <VirtualHost *:80>
      # The ServerName directive sets the request scheme, hostname and port that
      # the server uses to identify itself. This is used when creating
      # redirection URLs. In the context of virtual hosts, the ServerName
      # specifies what hostname must appear in the request's Host: header to
      # match this virtual host. For the default virtual host (this file) this
      # value is not decisive as it is used as a last resort host regardless.
      # However, you must set it for any further virtual host explicitly.
      #ServerName www.example.com

      ServerAdmin webmaster@localhost
      ServerName whattodoonline.com
      ServerAlias www.whattodoonline.com
      # Redirect permanent / https://www.mysite.com/
      DocumentRoot /var/www/html

      <Directory /var/www/html>
      Options Indexes FollowSymLinks MultiViews
      AllowOverride All
      Require all granted
      </Directory>


      # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
      # error, crit, alert, emerg.
      # It is also possible to configure the loglevel for particular
      # modules, e.g.
      #LogLevel info ssl:warn

      ErrorLog ${APACHE_LOG_DIR}/error.log
      CustomLog ${APACHE_LOG_DIR}/access.log combined

      # For most configuration files from conf-available/, which are
      # enabled or disabled at a global level, it is possible to
      # include a line for only one particular virtual host. For example the
      # following line enables the CGI configuration for this host only
      # after it has been globally disabled with "a2disconf".
      #Include conf-available/serve-cgi-bin.conf

      </VirtualHost>

      <VirtualHost *:443>
      ServerName <myip>
      DocumentRoot /var/www/html
      SSLEngine on
      SSLCertificateFile /etc/ssl/certs/apache-selfsigned.crt
      SSLCertificateKeyFile /etc/ssl/private/apache-selfsigned.key
      <Directory /var/www/html>
      DirectoryIndex index.php
      AllowOverride All
      Require all granted
      </Directory>
      </VirtualHost>

      # vim: syntax=apache ts=4 sw=4 sts=4 sr noet


      .htaccess file



      RewriteEngine On 

      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule ^([^/]+)/([^/]+)/([^/]+)$ index.php?page=$1&c=$2&d=$3&e=$4 [NC,L]

      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule ^([^/]+)/([^/]+)/([^/]+)$ index.php?page=$1&c=$2&d=$3 [NC,L]

      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule ^([^/]+)/([^/]+)$ index.php?page=$1&c=$2 [NC,L]

      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule ^([^/]+)$ index.php?page=$1 [NC,L]









      share|improve this question







      New contributor




      ii iml0sto1 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.












      I am setting up an UBUNTU 18.04 enviroment with apache, mysql, phpmyadmin etc etc.



      I need to allow HTTPS access for URL rewrites, currently HTTPS crash when i enter a URL which has been rewritten in .htaccess



      HTTPS:



      If i acces through HTTPS, only https://www.mysite.com works, if i try to access https://mysite.com/content/1 the website crash but if i try to access https://www.mysite.com?page=content&id=1 everything works and there is a HTTPS connection



      HTTP:



      If i access through HTTP there is no problems i can access all domains e.g http://mysite.com/user and http://mysite.com/content/1



      I found different tutorials and guides and i've come to the conclusion that i need to edit the Virtusl Hosts .cfg file



      <VirtualHost *:443>
      ServerName <myip>
      DocumentRoot /var/www/html
      SSLEngine on
      SSLCertificateFile /etc/ssl/certs/apache-selfsigned.crt
      SSLCertificateKeyFile /etc/ssl/private/apache-selfsigned.key
      <Directory /var/www/html>
      DirectoryIndex index.php
      AllowOverride All
      Require all granted
      </Directory>
      </VirtualHost>


      I need think that i need to get these 2 parts



      SSLCertificateFile      /etc/ssl/certs/apache-selfsigned.crt
      SSLCertificateKeyFile /etc/ssl/private/apache-selfsigned.key


      Where do i get these .crt and .key files?
      Do they have anything to do with SSL private/public keys? because these two files i have, but they do not have .crt and .key extensions HTTPS is however is enabled.



      Whole Config File



      <VirtualHost *:80>
      # The ServerName directive sets the request scheme, hostname and port that
      # the server uses to identify itself. This is used when creating
      # redirection URLs. In the context of virtual hosts, the ServerName
      # specifies what hostname must appear in the request's Host: header to
      # match this virtual host. For the default virtual host (this file) this
      # value is not decisive as it is used as a last resort host regardless.
      # However, you must set it for any further virtual host explicitly.
      #ServerName www.example.com

      ServerAdmin webmaster@localhost
      ServerName whattodoonline.com
      ServerAlias www.whattodoonline.com
      # Redirect permanent / https://www.mysite.com/
      DocumentRoot /var/www/html

      <Directory /var/www/html>
      Options Indexes FollowSymLinks MultiViews
      AllowOverride All
      Require all granted
      </Directory>


      # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
      # error, crit, alert, emerg.
      # It is also possible to configure the loglevel for particular
      # modules, e.g.
      #LogLevel info ssl:warn

      ErrorLog ${APACHE_LOG_DIR}/error.log
      CustomLog ${APACHE_LOG_DIR}/access.log combined

      # For most configuration files from conf-available/, which are
      # enabled or disabled at a global level, it is possible to
      # include a line for only one particular virtual host. For example the
      # following line enables the CGI configuration for this host only
      # after it has been globally disabled with "a2disconf".
      #Include conf-available/serve-cgi-bin.conf

      </VirtualHost>

      <VirtualHost *:443>
      ServerName <myip>
      DocumentRoot /var/www/html
      SSLEngine on
      SSLCertificateFile /etc/ssl/certs/apache-selfsigned.crt
      SSLCertificateKeyFile /etc/ssl/private/apache-selfsigned.key
      <Directory /var/www/html>
      DirectoryIndex index.php
      AllowOverride All
      Require all granted
      </Directory>
      </VirtualHost>

      # vim: syntax=apache ts=4 sw=4 sts=4 sr noet


      .htaccess file



      RewriteEngine On 

      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule ^([^/]+)/([^/]+)/([^/]+)$ index.php?page=$1&c=$2&d=$3&e=$4 [NC,L]

      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule ^([^/]+)/([^/]+)/([^/]+)$ index.php?page=$1&c=$2&d=$3 [NC,L]

      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule ^([^/]+)/([^/]+)$ index.php?page=$1&c=$2 [NC,L]

      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule ^([^/]+)$ index.php?page=$1 [NC,L]






      server apache2






      share|improve this question







      New contributor




      ii iml0sto1 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question







      New contributor




      ii iml0sto1 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question






      New contributor




      ii iml0sto1 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 5 hours ago









      ii iml0sto1ii iml0sto1

      1




      1




      New contributor




      ii iml0sto1 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      ii iml0sto1 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      ii iml0sto1 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          0






          active

          oldest

          votes











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "89"
          };
          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
          });


          }
          });






          ii iml0sto1 is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1125774%2fapache-allowing-https-inside-virtual-hosts-crf-file%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          ii iml0sto1 is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          ii iml0sto1 is a new contributor. Be nice, and check out our Code of Conduct.













          ii iml0sto1 is a new contributor. Be nice, and check out our Code of Conduct.












          ii iml0sto1 is a new contributor. Be nice, and check out our Code of Conduct.
















          Thanks for contributing an answer to Ask Ubuntu!


          • 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%2faskubuntu.com%2fquestions%2f1125774%2fapache-allowing-https-inside-virtual-hosts-crf-file%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

          GameSpot

          connect to host localhost port 22: Connection refused

          Getting a Wifi WPA2 wifi connection