ehm
By:
ehm

SSL and HTTPS:// and HTTP:// URL issues on WordPress Ubuntu 14.04

March 11, 2015 5.2k views
WordPress DNS Apache

We've been trying to figure out why after installing wordpress within the var/www/html directory on LAMP running ubuntu 14.04 (which is said to be the standard location for the uploaded files), that the SSL enabled site is not registering as one address, but as multiple addresses,(such that after WordPress installation completed from the browser on the https:// address, we'd check the http:// location and it would appear as an "Index of/ page just showing a folder directory icon titled "html", while the other https address correctly shows the page for a newly installed wp site. )
When WordPress was uninstalled, and then reinstalled from within the browser at the http:// location, the install program appeared within a subdirectory http://domain.com/html/wp-admin/install.php. After completion of the install, the site is shows up only from within the html/ subdirectory location, so if www.domain.com/wp-admin is typed, a "Not found" page shows. Any information would be greatly appreciated.

6 Answers

Can you post your site.conf file from /etc/apache2/sites-enabled

  • Within the /etc/apache2/sites-enabled subdirectory there is a .conf file titled 000-default.conf, its pretty much this.

    <VirtualHost *:80>
            ServerName domain.com
            ServerAlias www.domain.com
    </VirtualHost>
    
    <VirtualHost *:443>
            ServerName domain.com
            ServerAlias www.domain.com
    
            # The ServerName directive sets the request scheme, hostname and port t$
            # 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.
    
            ServerAdmin webmaster@domain.com
            DocumentRoot /var/www/html
            SSLEngine on
            SSLCertificateFile /home/me/domain.com.crt
            SSLCertificateKeyFile /home/me/domain.com.key
            SSLCACertificateFile  /home/me/domain.com.crt
    
            # 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>
    
    # vim: syntax=apache ts=4 sw=4 sts=4 sr noet
    

    unsure if there is something that was not specified or left out accidentally. Any help would be greatly appreciated. Thanks.

try this on your 000-default.conf, and then reload or restart apache :


<VirtualHost *:80>
        ServerName domain.com
        ServerAlias www.domain.com


      DocumentRoot /var/www/html
      ErrorLog ${APACHE_LOG_DIR}/error.log
      CustomLog ${APACHE_LOG_DIR}/access.log combined

    <Directory /var/www/html>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
                Require all granted
    </Directory>

</VirtualHost>

<VirtualHost *:443>
        ServerName domain.com
        ServerAlias www.domain.com


    <Directory /var/www/html>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
                Require all granted
    </Directory>


        ServerAdmin webmaster@domain.com
        DocumentRoot /var/www/html
        SSLEngine on
        SSLCertificateFile /home/me/domain.com.crt
        SSLCertificateKeyFile /home/me/domain.com.key
        SSLCACertificateFile  /home/me/domain.com.crt


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


</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
  • Thanks! sierracircle your suggestion worked perfectly. Just wondering if the site could automatically load without the www prefix for both http and https, so if someone types www.domain.com the server would send the visitor to domain.com on either the https or the http variant of the site. Thanks again for the help.

  • Worked Beautifully! Thank you for sharing!

Yes, you can do that. Insert this into your .htaccess file (located in your website folder):

#redirect www to website root
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]

  • Thank you again, will try this as soon as we've gotten the website migrated over to the production server. Much appreciated.

Hi,

I have Ubuntu 14.04 and using WordPress multi-site with sub-directory installation. I have installed SSL certificate following the below tutorial.

https://www.digitalocean.com/community/tutorials/how-to-create-a-ssl-certificate-on-apache-for-ubuntu-14-04

Problem is, if I check the home page it is working fine with https:// but if I check any page of the site, it is showing the below 404 error with https://


"Not Found

The requested URL /login/ was not found on this server.

Apache/2.4.7 (Ubuntu) Server at {mysiteurl} Port 443


I even added define(FORCESSLADMIN, true); in my wp-config,php but of no use. It is showing 404

Please confirm whether any special settings are to be done in WordPress for SSL certificate.

If I am replacing http:// with https:// in my database it is showing "Error establishing database connection" or 404 to every page except home page.

by Justin Ellingwood
The Apache web server is the most popular way to serve content on the web. If you need to communicate with your site visitors over a secured connection, setting up a TLS or SSL certificate will enable you to encrypt traffic. In this guide, we'll discuss how to create a self-signed SSL certificate on Ubuntu 14.04 and use it with Apache to encrypt traffic.
  • I am having the exact same problem and I have not seen a solution anywhere within the DO community.

  • Hi,

    well I have same issue you mentioned and just figured it, here is steps:

    1. open you default-ssl.conf file and paste this code (inside VirtualHost *:443)
    <Directory /var/www/html>
                    Options Indexes FollowSymLinks MultiViews
                    AllowOverride All
                    Order allow,deny
                    allow from all
                            Require all granted
            </Directory>
    

    your default-ssl.conf should like this:

    <IfModule mod_ssl.c>
            <VirtualHost *:443>
                    ServerAdmin webmaster@localhost
                    ServerName zumidia.com:443
                    DocumentRoot /var/www/html
            <Directory /var/www/html>
                    Options Indexes FollowSymLinks MultiViews
                    AllowOverride All
                    Order allow,deny
                    allow from all
                            Require all granted
            </Directory>
    
    ..... REST OF THE FILE CODE .....
    

    Save the fie and exit editor

    1. disable site like: a2dissite default-ssl.conf
    2. Restart apache like: service apache2 reload
    3. Now enable site like: a2ensite default-ssl.conf 5 Restart apache again like: service apache2 reload

    It did the trick for me.

I enabled HTTP2 after struggling a lot and now internal pages (wordpress) are not working. 404 error.

https://misg.in

Have another answer? Share your knowledge.