Magento – 404 after switching to https

404-pagehttpsmagento1.9.3

I have a Wildcard SSL certificate and yesterday I have asked to siteground to extend it to all my subdomains, the result is that today any https url throw the 404 error (except for index.php/homepage).

Is it a problem of configuration or a bad installation of the certificate?

  • I have tried to do not use the https and everything works fine
  • I have just changed the config under System>General>Web>Secure and then cleaned up sessions, cache and memcache, restored file permission and reindexed the information, but with no luck.

    This is my .htaccess in my magento folder:

    #AddType x-mapp-php5 .php
    #AddHandler x-mapp-php5 .php
    
    DirectoryIndex index.php
    
    <IfModule mod_php5.c>
    
    php_value memory_limit 256M
    php_value max_execution_time 18000
    
    
    php_flag magic_quotes_gpc off
    
    
    php_flag session.auto_start off
    
    
    #php_flag zlib.output_compression on
    
    
    php_flag suhosin.session.cryptua off
    
    
    
    php_flag zend.ze1_compatibility_mode Off
    
    </IfModule>
    
    <IfModule mod_security.c>
    
    
    SecFilterEngine Off
    SecFilterScanPOST Off
    </IfModule>
    
    <IfModule mod_deflate.c>
    
    
    <IfModule mod_ssl.c>
    
    
    SSLOptions StdEnvVars
    
    </IfModule>
    
    <IfModule mod_rewrite.c>
    
    
    Options +FollowSymLinks
    RewriteEngine on
    
    
    
    
    RewriteRule ^api/rest api.php?type=rest [QSA,L]
    
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    
    RewriteCond %{REQUEST_METHOD} ^TRAC[EK]
    RewriteRule .* - [L,R=405]
    
    <IfModule mod_setenvif.c>
    <IfModule mod_headers.c>
    
        Header set X-Content-Type-Options: nosniff
    
        BrowserMatch \bMSIE\s8 ie8
        Header set X-XSS-Protection: "1; mode=block" env=!ie8
    
    </IfModule>
    </IfModule>
    
    #RewriteCond %{REQUEST_URI} !^/mobiledirectoryhere/.*$
    #RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
    #RewriteRule ^(.*)$ /mobiledirectoryhere/ [L,R=302]
    
    RewriteCond %{REQUEST_URI} !^/(media|skin|js)/
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l
    
    
    RewriteRule .* index.php [L]
    
    </IfModule>
    
    AddDefaultCharset Off
    #AddDefaultCharset UTF-8
    
    <IfModule mod_expires.c>
    
    ExpiresDefault "access plus 1 year"
    
    </IfModule>
    
    Order allow,deny
    Allow from all
    
    
    <Files RELEASE_NOTES.txt>
        order allow,deny
        deny from all
    </Files>
    
    #FileETag none
    
    
    <Files cron.php>
    
    
        #AuthName "Cron auth"
        #AuthUserFile ../.htpasswd
        #AuthType basic
        #Require valid-user
    
        Order allow,deny
        Deny from all
    
    </Files>
    

EDIT

  • I'm using magento 1.9.3.1
  • Admin area works fine

    EDIT 2
    Setting:
    settings

Best Answer

I encountered this same issue while testing out a switch to full https. Home page and admin pages worked fine via https, but all other pages gave a 404.

In my case the root cause was an error in my Apache configuration. Since Apache listens on a separate port for https:// (443 rather than 80) it also has a separate virtual host. On my Ubuntu server the config files were at these paths:

/etc/apache2/sites-available/000-default.conf (port 80)
/etc/apache2/sites-available/default-ssl.conf (port 443)

While the 000-default.conf file had an AllowOverride All declaration as shown below, this was missing from the default-ssl.conf.

<VirtualHost *:80>

  <Directory "/var/www/html">
    AllowOverride All
  </Directory>

</VirtualHost>

After adding the directory node and AllowOverride All to the port 443 virtual host in default-ssl.conf, the 404 errors went away. I believe the issue was that Magento relies on the .htaccess file for url rewrites to work on the front end, and Apache only parses .htaccess files when the AllowOverride All declaration is present. Therefore url rewrites didn't work, thus the 404s. Home page doesn't need a rewrite so it worked, and the admin doesn't use rewrites so it worked fine too.

Related Topic