Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

Consider the following URL : http://www.myurl.fr/accueil.

It won't work. However http://www.myrurl.fr/app.php/accueil does work.

I got rid of the .htaccess file because I want to use the vhost file and rely on Apache routing. My vhost file is as follow:

<VirtualHost my.ip.address>
ServerName myurl.fr
ServerAlias www.myurl.fr
DocumentRoot /var/www/mysite/web
DirectoryIndex app.php
<Directory "/var/www/mysite/web">
  AllowOverride All
  Allow from All
</Directory>

<IfModule mod_rewrite.c>
 RewriteEngine On  
 RewriteCond %{ENV:REDIRECT_STATUS} ^$  
 RewriteRule ^app\.php(/(.*)|$) %{CONTEXT_PREFIX}/$2 [R=301,L]
 RewriteRule .? - [L]
 RewriteCond %{REQUEST_FILENAME} -f
 RewriteRule ^(.*)$ app.php [QSA,L]
 RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$
 RewriteRule ^(.*) - [E=BASE:%1]    
 RewriteRule .? %{ENV:BASE}app.php [L]
</IfModule>
</VirtualHost>

I've cleared Apache cache and restarted it many times. The urlrewrite mod is enabled. I just don't know what else to check. Any idea what I'm missing ?

EDIT It could be that both URL won't work at a given time since I'm working on it. My issue is still valid.

share|improve this question
 
You can change AllowOverride All to AllowOverride None. Unlikely to solve your issue tho. –  cheesemacfly Aug 16 '13 at 20:22
 
yes, that's not going to solve my issue :) –  Sam Aug 16 '13 at 20:23
add comment

2 Answers

up vote 3 down vote accepted

Compared your rules with symfony-standard .htaccess, I saw that you missed file checking before 'pass everything rule'. Try to

<IfModule mod_rewrite.c>
    RewriteEngine On  

    RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
    RewriteRule ^(.*) - [E=BASE:%1]
    RewriteCond %{ENV:REDIRECT_STATUS} ^$
    RewriteRule ^app\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]
    # If the requested filename exists, simply serve it.
    # We only want to let Apache serve files and not directories.
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteRule .? - [L]

    # Rewrite all other queries to the front controller.
    RewriteRule .? %{ENV:BASE}/app.php [L]
</IfModule>
share|improve this answer
 
that works indeed ! however my css, images and scripts are no longer found. How do I solve that ? I guess I should have a rule to ignore rewriting of these types of file ? –  Sam Aug 17 '13 at 17:44
 
ok I've added three rules to ignore css, img and js folders so they don't get rewritten. I've edited your answer with these 3 rules so I can mark it as answer. Thanks a lot. –  Sam Aug 17 '13 at 19:10
add comment

change the apache httpd.conf virtual host code to this

ServerName my-site.fr
<VirtualHost your.ip.address:80>
DocumentRoot /var/www/mysite/web
<Directory "/var/www/mysite/web">
DirectoryIndex app.php
Options -Indexes FollowSymLinks SymLinksifOwnerMatch
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.