mod_rewrite not working for a specific directory

Posted by punkish on Stack Overflow See other posts from Stack Overflow or by punkish
Published on 2009-10-05T21:16:30Z Indexed on 2010/05/28 16:01 UTC
Read the original article Hit count: 235

Filed under:
|

This has got me completely foxed for a couple of days now, and I am convinced that I will look stupid once I solve it, but will be even stupider if I don't ask for help now.

I have mod_rewrite working successfully on my localhost (no vhosts involved; this is my laptop, my development machine), and I use .htaccess in various directories to help rewrite crufty URLs to clean ones. EXCEPT... it doesn't work in one directory. Since it is impossible to reproduce my entire laptop in this question, I provide the following details.

In my httpd.conf, I have mod_rewrite.so loaded.

LoadModule rewrite_module modules/mod_rewrite.so

In my httpd.conf, I have included another conf file like so

Include /usr/local/apache2/conf/other/punkish.conf

In my punkish.conf, I have directories defined like so

DocumentRoot "/Users/punkish/Sites"
<Directory "/Users/punkish/Sites">
  Options ExecCGI
  AllowOverride None
  Order allow,deny
  Allow from all
</Directory>

<Directory "/Users/punkish/Sites/one">
  Options FollowSymLinks
  AllowOverride All
  Order allow,deny
  Allow from all
</Directory>

<Directory "/Users/punkish/Sites/two">
  Options FollowSymLinks
  AllowOverride All
  Order allow,deny
  Allow from all
</Directory>

In ~/Sites/one I have the following .htaccess file

RewriteEngine On
RewriteBase /one/

# If an actual file or directory is requested, serve directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Otherwise, pass everything through to the dispatcher
RewriteRule ^(.*)$ index.cgi/$1 [L,QSA]

and, everything works just fine. However, in my directory ~/Sites/two I have the following .htaccess file

RewriteEngine On
RewriteBase /two/

# If an actual file or directory is requested, serve directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Otherwise, pass everything through to the dispatcher
RewriteRule ^(.*)$ index.cgi/$1 [L,QSA]

and, nothing works. Nada. Zip. Zilch. I just get a 404. I have determined that mod_rewrite is not even looking at my ~/Sites/two/.htaccess by putting spurious commands in it and not getting any error other than 404.

Another confounding issue -- I have turned on RewriteLog in my httpd.conf with RewriteLogLevel 3, but my rewrite_log is completely empty. I know this is hard to trouble shoot unless sitting physically at the computer in question, but I hope someone can give me some indication as to what is going on.

**Update: ** There are no aliases involved anywhere. This is my laptop, and everything is under the above stated Document Root, so I just access each directory as http://localhost/. Yes, typos are a big possibility (I did say that I will look stupid once I solve it, however, for now, I have not discovered a single typo anywhere, and yes, I have restarted Apache about a dozen times now. I even thought that perhaps I had two different Apaches running, but no, I have only one, the one under /usr/local/apache2, and I installed it myself a while back.

© Stack Overflow or respective owner

Related posts about .htaccess

Related posts about mod-rewrite