Mahavir Munot
Mahavir Munot

Reputation: 1464

Hide index.php for "https" connection?

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.

Upvotes: 2

Views: 884

Answers (2)

Yura Rodchyn
Yura Rodchyn

Reputation: 716

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

Upvotes: 1

j0k
j0k

Reputation: 22756

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.

Upvotes: 0

Related Questions