404 error for mod_rewrite using SSL and MAMP

I am creating an application in Zend Framework at the moment and testing it locally. I have Mamp Pro as my web server and I have a self signed SSL that seems to work. My problem comes when I try to do mod_rewrite - I just get 404 pages.

How I created things (which might not be the best way ...)


In Mamp, I have 2 virtual hosts configured for both the same web directory (webroot / public /):

  • secure.myapp.com
  • myapp.com

My public directory contains my index.php file and my .htaccess file. Htaccess file content:

SetEnv APPLICATION_ENV development
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

      

When I visit http://myapp.com all routes are like when using mod_rewrite. But when I go to https://secure.myapp.com the index page is fine, but url routing stops working and the .htaccess file seems to be ignored.

In my ssl.conf I have the following:

<IfModule mod_ssl.c>

Listen 443
AddType application/x-x509-ca-cert .crt
AddType application/x-pkcs7-crl    .crl
SSLPassPhraseDialog  builtin
SSLSessionCache         dbm:/Applications/MAMP/logs/ssl_scache
SSLSessionCacheTimeout  300
SSLMutex  file:/Applications/MAMP/logs/ssl_mutex

<VirtualHost _default_:443>

SSLEngine on
DocumentRoot "/webroot/public"
ServerName secure.myapp.com
ServerAdmin you@example.com
ErrorLog /Applications/MAMP/logs/ssl_error_log
TransferLog /Applications/MAMP/logs/ssl_access_log

SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
SSLCertificateFile /Applications/MAMP/conf/apache/ssl_cert/server.crt
SSLCertificateKeyFile /Applications/MAMP/conf/apache/ssl_key/server.key

CustomLog /Applications/MAMP/logs/ssl_request_log \
          "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"

</VirtualHost>

</IfModule>

      

Does anyone have any ideas on this? I will be very grateful for your help, as it seriously interferes with my development!

+2


source to share


1 answer


Ok, I'm pretty sure it works for me. Basically the big problem I am facing is that Mamp does not store the vhosts.conf as an accessible file. Instead, it is an application alias file.

I think what is happening is that the virtual hosts are all dynamically created on the standard http port, in my case 80. However, I needed to have access to the vhost config for port 433 in order to enable FileInfo. So my workaround is to cut the .htaccess file and paste the following ALL file into the ssl.conf file.

<IfModule mod_ssl.c>

Listen 443
AddType application/x-x509-ca-cert .crt
AddType application/x-pkcs7-crl    .crl
SSLPassPhraseDialog  builtin
SSLSessionCache         dbm:/Applications/MAMP/logs/ssl_scache
SSLSessionCacheTimeout  300
SSLMutex  file:/Applications/MAMP/logs/ssl_mutex

<VirtualHost mysite.com:443>

    SSLEngine on
    DocumentRoot /webroot/secure
    ServerName mysite.com
    ServerAdmin you@example.com
    ErrorLog /Applications/MAMP/logs/ssl_error_log
    TransferLog /Applications/MAMP/logs/ssl_access_log

    SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
    SSLCertificateFile /Applications/MAMP/conf/apache/ssl_cert/server.crt
    SSLCertificateKeyFile /Applications/MAMP/conf/apache/ssl_key/server.key

    CustomLog /Applications/MAMP/logs/ssl_request_log \
              "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"

    DirectoryIndex index.php

        <IfModule mod_rewrite.c>
            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]

            RewriteLog /Applications/MAMP/logs/ssl_rewrite_log
            RewriteLogLevel 3
        </IfModule>

</VirtualHost>

</IfModule>

      



I had to add DOCUMENT_ROOT before my file and directory checks and a forward slash before index.php. If I could put this in the "Directory" then I think I could avoid these changes, but Apache won't restart when this parameter is added.

The only thing I haven't tried is adding information to the MAMP httpd.conf, but I feel like there might be the same limitations.

0


source







All Articles