2

I want to hide "index.php" from the URL but it doesn't work at all. I have tried lot of stuff through google, stack but it did not help me at all. I have the following rules specified in my .htaccess file. Also when I access the URL using "https://www.domain.com/index.php/login" it works fine but when I access the site using "https://www.domain.com/login" then it shows 404 page (Page not found). I am not sure if I am missing something. [Note: I am using symfony 1.4, I also tried using the filters like http://www.symfony-project.org/plugins/lapeSSLFilterPlugin for handling ssl but it doesn't work. I have also checked the error log for ssl but I am not getting any relevant error in the log.]

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>

The ssl.conf file contains the below 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>

The httpd.conf file contains the below vhost settings:

<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>

Any help will be greatly appreciated.

j0k
  • 22,600
  • 28
  • 79
  • 90
Mahavir Munot
  • 1,464
  • 2
  • 22
  • 47
  • Duplicate of http://stackoverflow.com/q/905030/212940? – vascowhite May 11 '12 at 07:17
  • Look at the accepted answer, it should work for you too. If you read my comment carefully you'll see a '?' at the end which means it is a question. It was meant to help you, so don't get upset. – vascowhite May 11 '12 at 07:23
  • @vascowhite:apology. I tried that as well but it did not help. Thank you for your response. – Mahavir Munot May 11 '12 at 07:30

2 Answers2

1

Probles is in you symfony configuration. All apache config files is ok.

You need add this in global security.yml

default:
  is_secure: false
  is_ssl: true

sfGuardAuth/config/security.yml

secure:
  is_secure: false
  is_ssl: true

signin:
  is_secure: false
  is_ssl: true

signout:
  is_secure: false

And if you want no "index.php" in your URLs set

no_script_name:         true

in your global app settings.yml

Yura Rodchyn
  • 716
  • 5
  • 3
0

Is the site work without index.php and http (not https) ?

If the site isn't working in http without https, the problem could be on the symfony part. Could you show us your apps/[your apps]/config/settings.yml ? Particular look for the options no_script_name:

The no_script_name setting determines whether the front controller script name is prepended to generated URLs or not. By default, it is set to true by the generate:app task for the prod environment of the first application created.

j0k
  • 22,600
  • 28
  • 79
  • 90
  • The no_script_name is set to false for all environment. I guess I am missing something in ssl.conf or httpd.conf. can you please take a look – Mahavir Munot May 14 '12 at 12:23
  • I don't see what could be wrong, is your site work on http without index.php ? Did you enable [mod_rewrite log](http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#rewritelog) (RewriteLog & RewriteLogLevel > 3)? – j0k May 14 '12 at 12:36
  • yes the site works fine without index.php when I use http connection. [i.e.: http://www.domain.com/login]. Also the Rewrite is enabled to 5. – Mahavir Munot May 14 '12 at 12:58
  • I think it's better for every one if we can solve the problem here instead of in private. What does the RewriteLog file says about the 404? – j0k May 14 '12 at 13:19
  • :it cannot find the /login in "/var/www/html/domain/web/" – Mahavir Munot May 14 '12 at 13:26
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/11233/discussion-between-mahavir-munot-and-j0k) – Mahavir Munot May 14 '12 at 13:44