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.

3
  • Duplicate of stackoverflow.com/q/905030/212940? Commented May 11, 2012 at 7: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. Commented May 11, 2012 at 7:23
  • @vascowhite:apology. I tried that as well but it did not help. Thank you for your response. Commented May 11, 2012 at 7:30

2 Answers 2

1
+50

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

Sign up to request clarification or add additional context in comments.

1 Comment

be careful, it's coming from a plugin, not from symfony itself.
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.

6 Comments

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
I don't see what could be wrong, is your site work on http without index.php ? Did you enable mod_rewrite log (RewriteLog & RewriteLogLevel > 3)?
yes the site works fine without index.php when I use http connection. [i.e.: domain.com/login]. Also the Rewrite is enabled to 5.
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?
:it cannot find the /login in "/var/www/html/domain/web/"
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.