2012-05-11 61 views
2

我想隱藏URL中的「index.php」,但它根本不起作用。我通過谷歌,堆棧嘗試了很多東西,但它根本沒有幫助我。我有我的.htaccess文件中指定的以下規則。另外,當我使用「https://www.domain.com/index.php/login」訪問URL時,它工作正常,但是當我使用「https://www.domain.com/login」訪問網站時,它顯示404頁(找不到頁面)。我不確定我是否缺少一些東西。 [注:我使用symfony 1.4,我也嘗試使用像http://www.symfony-project.org/plugins/lapeSSLFilterPlugin這樣的過濾器來處理ssl,但它不起作用。我還檢查錯誤日誌的SSL,但我不會在日誌中得到任何相關的錯誤]隱藏「https」連接的index.php?

Options +FollowSymLinks +ExecCGI 
<IfModule mod_rewrite.c> 
    RewriteEngine On 

    # uncomment the following line, if you are having trouble 
    # getting no_script_name to work 
    RewriteBase/

    # we skip all files with .something 
    #RewriteCond %{REQUEST_URI} \..+$ 
    #RewriteCond %{REQUEST_URI} !\.html$ 
    #RewriteRule .* - [L] 

    # we check if the .html version is here (caching) 
    RewriteRule ^$ index.html [QSA] 
    RewriteRule ^([^.]+)$ $1.html [QSA] 
    RewriteCond %{REQUEST_FILENAME} !-f 

    # no, so we redirect to our front web controller 
    RewriteCond %{SERVER_PORT} !^443$ 
    RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI}  [R=301,L] 
    RewriteRule ^(.*)$ index.php [QSA,L] 
</IfModule> 

ssl.conf文件包含以下entires:

LoadModule ssl_module modules/mod_ssl.so 
Listen 443 

<VirtualHost _default_:443> 
    DocumentRoot /var/www/html/domain/web 
    ServerName www.domain.com 
    RewriteEngine On 
    DirectoryIndex index.php 
    Alias /sf /var/www/html/domain/lib/vendor/symfony/data/web/sf 
    <Directory "/var/www/html/domain/lib/vendor/symfony/data/web/sf"> 
     AllowOverride All 
     Allow from All 
    </Directory> 
    <Directory "/var/www/html/domain/web"> 
     AllowOverride All 
     Allow from All 
    </Directory> 

    ErrorLog logs/ssl_error_log 
    TransferLog logs/ssl_access_log 
    LogLevel warn 

    SSLEngine on 
    SSLCertificateFile /etc/ssl/certs/domain.com.crt 
    SSLCertificateKeyFile /etc/ssl/certs/domain.key 
    SSLCertificateChainFile /etc/ssl/certs/gd_bundle.crt 
    SSLCACertificateFile /etc/ssl/certs/gd_bundle.crt 
</VirtualHost> 

在httpd.conf文件包含下面的虛擬主機設置:

<VirtualHost *:80> 
    ServerName www.domain.com 
    DocumentRoot "/var/www/html/domain/web" 
    DirectoryIndex index.php 
    RewriteEngine On 
    <Directory "/var/www/html/domain/web"> 
    AllowOverride All 
    Allow from All 
    </Directory> 
    Alias /sf /var/www/html/domain/lib/vendor/symfony/data/web/sf 
    <Directory "/var/www/html/domain/lib/vendor/symfony/data/web/sf"> 
     AllowOverride All 
     Allow from All 
    </Directory> 
</VirtualHost> 

任何幫助將不勝感激。

+0

重複的http://stackoverflow.com/q/905030/212940? – vascowhite

+0

看看接受的答案,它也適用於你。如果你仔細閱讀我的評論,你會看到一個'?'最後意味着這是一個問題。它旨在幫助你,所以不要感到不安。 – vascowhite

+0

@vascowhite:道歉。我也嘗試過,但沒有幫助。感謝您的答覆。 –

回答

1

Probles在你的symfony配置中。 所有的Apache配置文件都可以。

您需要在全球security.yml

default: 
    is_secure: false 
    is_ssl: true 

sfGuardAuth /配置/ security.yml

secure: 
    is_secure: false 
    is_ssl: true 

signin: 
    is_secure: false 
    is_ssl: true 

signout: 
    is_secure: false 

如果你不想要 「的index.php」 在你的URL設置

添加此
no_script_name:   true 

在您的全球應用程序settings.yml

+0

is_ssl對我來說是新鮮事,謝謝! – Prasad

+1

要小心,它來自插件,而不是來自symfony本身。 – j0k

0

該網站的工作沒有index.php和http(不是https)?

如果該網站在沒有https的http下工作,問題可能在symfony部分。你能告訴我們你的apps/[your apps]/config/settings.yml嗎?特定的外觀的選項no_script_name

no_script_name設置確定前端控制器 腳本名稱是否被預置到生成的URL或沒有。默認情況下,它是 設置爲truegenerate:app任務爲prod環境的 創建的第一個應用程序。

+0

對於所有環境,no_script_name都設置爲false。我想我在ssl.conf或httpd.conf中缺少一些東西。你可以看看 –

+0

我沒有看到什麼可能是錯的,你的網站工作http沒有index.php?你是否啓用了[mod_rewrite日誌](http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#rewritelog)(RewriteLog&RewriteLogLevel> 3)? – j0k

+0

是的,該網站工作正常,沒有index.php當我使用http連接。 [即:http://www.domain.com/login]。此外,重寫啓用爲5。 –