This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use Stack Overflow.

htaccess rewrite not working

Discuss installing Symfony 2 here

htaccess rewrite not working

by gt_ccraze » Thu Oct 10, 2013 2:59 am

I'm trying to set up a symfony project in a virtual host on a Mac (Mountain Lion, using Apple's stock builds of Apache and PHP).

I've verified that mod_rewrite is loaded, and as far as I can tell the virtual host configuration is good:
Code: Select all
<VirtualHost *:80>
  ServerAdmin root@localhost
  DocumentRoot "/Users/gt/Sites/cms/Symfony/web/"
  ServerName cms.localdomain
  ServerAlias cms.localhost cms
  Header set Access-Control-Allow-Origin "*"
  DirectoryIndex app.php
  ErrorLog /var/log/apache2/cms_error_log
  CustomLog /var/log/apache2/cms_access_log combined
  <Directory /Users/gt/Sites/cms/Symfony/web/">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride all
  </Directory>
</VirtualHost>


The .htaccess file is unmodified from what came with Symfony 2.3.

http://cms.localdomain/cms consistently returns 404. Naturally, http://cms.localdomain/app.php/cms works fine.

mod_rewrite logging is currently turned on with log level 9 (way too high for normal use, of course, but right now rewrite_log is consistently at zero bytes).

I've tried moving the rewrite rules into the vhost configuration, but that didn't help.

A basically identical vhost configuration (all the same except the filesystem path) on CentOS works fine (but I'd like to be able to develop locally on my Mac...)

Any other suggestions, or anything obviously wrong with this setup?
gt_ccraze
Junior Member
 
Posts: 3
Joined: Thu Oct 10, 2013 2:48 am

Re: htaccess rewrite not working

by gt_ccraze » Tue Oct 15, 2013 1:57 am

Following up with a couple of other things I've tried:
  • Duplicating the vhost definition (with a different ServerName and pointing to a different directory) and setting up an entirely new copy of Symfony (either via Composer or via downloaded tar.gz) - has the same problem
  • Setting up a matching vhost definition and installing Wordpress with its default .htaccess rules - works fine. (I believe this safely rules out mod_rewrite as the problem, since Wordpress also depends on it. Also, the Wordpress rewrite rules wrote several KB to that level-9 rewrite log file...)
  • Borrowing the .htaccess rules from Wordpress and adjusting to use app.php instead of index.php - still has the same problem as before.
  • Order allow,deny and Allow from all rules are inherited from the main httpd.conf, but setting those rules again explicitly in the vhost does not help.
gt_ccraze
Junior Member
 
Posts: 3
Joined: Thu Oct 10, 2013 2:48 am

Re: htaccess rewrite not working

by gt_ccraze » Thu Oct 31, 2013 12:42 am

I finally found the problem (doing a line by line comparison with a working vhost configuration from another computer.)

It was the trailing double quote in the <Directory /Users/gt/Sites/cms/Symfony/web/"> line.

No idea how I've managed to miss that over and over again (or why it ever passed apachectl configtest at all), but removing the double quote did fix it.
gt_ccraze
Junior Member
 
Posts: 3
Joined: Thu Oct 10, 2013 2:48 am