Fix Zend Framework 404 routes on HTTPS

I’ve been working on a web project that required some of the pages to be loaded via HTTPS.

I’ve got the certificate, installed accessed homepage via HTTPS and seems to work. That was not the case for the rest of the routes. After a lot of searching i was able to find a post which proposes a fix for this. Namely, you have to add what’s on your app’s main .htaccess into your SSL virtualhost.

Add the following just before tag closes and you should be fine:

        
                RewriteEngine on
                RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} -s [OR]
                RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} -l [OR]
                RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} -d

                RewriteRule ^.*$ - [NC,L]
                RewriteRule ^.*$ /index.php [NC,L]

        

Another one of my requirements was to redirect some pages to HTTPS (ie a login page). To do that add the following to your .htaccess:

RewriteCond %{HTTPS} !=on
RewriteRule ^login(.*) https://%{SERVER_NAME}/login$1 [R,L]

2 thoughts on “Fix Zend Framework 404 routes on HTTPS”

Leave a Reply

Your email address will not be published. Required fields are marked *