2009-09-24 68 views
2

我正在Zend Framework中構建一個應用程序,並在本地測試它。我有Mamp Pro作爲我的網絡服務器,我有一個自簽名的SSL,這似乎都工作。我的問題來了,當我嘗試做mod_rewrite - 我只是得到404頁。mod_rewrite 404錯誤使用SSL和MAMP

我有事情設置方式(這可能不是最好的辦法...)


爲毫安我有2個virtualhosts設置都指向同一個網站目錄(Webroot公司/公共/ ):

  • secure.myapp.com
  • myapp.com

在我的公開目錄是我的IND ex.php文件和我的.htaccess文件。 .htaccess文件的內容是:

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] 

當我訪問http://myapp.com一切的路線,因爲它應該使用mod_rewrite的。但是,當我去https://secure.myapp.com索引頁是好的,但URL路由停止工作,它似乎是.htaccess文件被忽略。

在我的ssl.conf我有以下幾點:

<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 [email protected] 
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> 

是否有人對此有什麼想法?我會非常感激這種幫助,因爲它嚴重阻礙了我的發展!

+0

您是否爲該目錄設置了「AllowOverride FileInfo」?你看看錯誤日誌嗎? – Gumbo 2009-09-24 19:54:30

+0

Gumbo,我想我的問題是我無法使用MAMP設置任何目錄特定的覆蓋。我需要在偵聽端口443的VirtualHost中設置,但是當我嘗試這樣做時,MAMP不會讓我啓動Apache。我想我已經解決了它...查看我的答案。 – wiseguydigital 2009-09-24 20:19:56

回答

0

嗯,我很確定我有這個工作。基本上,我遇到的一個大問題是Mamp不會將vhosts.conf存儲爲可訪問的文件。相反,這是一個別名應用程序文件。

我認爲會發生什麼是虛擬主機都動態創建的所有標準http端口,在我的情況下80.但是我需要能夠訪問端口433 vhost配置啓用FileInfo。所以我的解決方法是放棄我的.htaccess文件並將以下所有內容粘貼到我的ssl.conf文件中。

<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 [email protected] 
    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> 

我必須在我的文件和目錄的檢查,並在index.php中的前一個斜槓前加DOCUMENT_ROOT。如果我可以將它放到「目錄」中,那麼我認爲我可以避免這些更改,但是當我添加此參數時,Apache將不會重新啓動。

我沒有嘗試過的唯一的事情是將信息添加到MAMP的httpd.conf中,但我有一種感覺,可能會有相同的限制。