1

I'm currently having issues with getting Apache2 to recognize an .htaccess file. I'm currently running the server locally on my machine for testing purposes. I can get my index page to load up without issue but anytime I would navigate to a page that matches a pattern from the .htaccess file, I get a 404 error. Here is a sample of both my default.conf file and .htaccess file.

default.conf

NameVirtualHost *
<VirtualHost *>
ServerAdmin webmaster@localhost

DocumentRoot /var/www/  
<Directory />
    Options FollowSymLinks
    AllowOverride All
</Directory>
<Directory /var/www/>   
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
    Require all granted
</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
    AllowOverride None
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    Order allow,deny
    Allow from all
</Directory>

ErrorLog /var/log/apache2/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog /var/log/apache2/access.log combined
ServerSignature On

Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
    Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>

.htaccess

# Prevent Directoy listing 
Options -Indexes +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_URI}  !index\.php/?  [NC]
RewriteCond %{REQUEST_URI}  ^/([^/]+)/?.*/?  [NC]
RewriteRule ^(.*)  /api/index.php?/$1     [QSA,P,L]

As you can see from the default.conf I have AllowOverride set to All, which is usually the most common problem. I have the correct Apache mods enabled as well. Also, I don't believe it to be a permissions issues either. I've gone over a multitude of Server Fault and Stack Overflow posts but to know avail. Is there something else I could be missing? Any help is greatly appreciated.

Update: Here is a dump of my rewrite logs:

[Sun Mar 09 00:07:45.752577 2014] [rewrite:trace3] [pid 10168] mod_rewrite.c(468): [client 127.0.0.1:37380] 127.0.0.1 - - [localhost/sid#b63dbc90][rid#b663e058/initial] [perdir /media/lnendza/Storage/workspace/CheckMate/Heffalump/site/api/] add path info postfix: /media/lnendza/Storage/workspace/CheckMate/Heffalump/site/api/v1 -> /media/lnendza/Storage/workspace/CheckMate/Heffalump/site/api/v1/i/login, referer: http://localhost/login.php
[Sun Mar 09 00:07:45.752608 2014] [rewrite:trace3] [pid 10168] mod_rewrite.c(468): [client 127.0.0.1:37380] 127.0.0.1 - - [localhost/sid#b63dbc90][rid#b663e058/initial] [perdir /media/lnendza/Storage/workspace/CheckMate/Heffalump/site/api/] strip per-dir prefix: /media/lnendza/Storage/workspace/CheckMate/Heffalump/site/api/v1/i/login -> v1/i/login, referer: http://localhost/login.php
[Sun Mar 09 00:07:45.752614 2014] [rewrite:trace3] [pid 10168] mod_rewrite.c(468): [client 127.0.0.1:37380] 127.0.0.1 - - [localhost/sid#b63dbc90][rid#b663e058/initial] [perdir /media/lnendza/Storage/workspace/CheckMate/Heffalump/site/api/] applying pattern '^(.*)' to uri 'v1/i/login', referer: http://localhost/login.php
[Sun Mar 09 00:07:45.752630 2014] [rewrite:trace2] [pid 10168] mod_rewrite.c(468): [client 127.0.0.1:37380] 127.0.0.1 - - [localhost/sid#b63dbc90][rid#b663e058/initial] [perdir /media/lnendza/Storage/workspace/CheckMate/Heffalump/site/api/] rewrite 'v1/i/login' -> '/api/index.php?/v1/i/login', referer: http://localhost/login.php
[Sun Mar 09 00:07:45.752636 2014] [rewrite:trace3] [pid 10168] mod_rewrite.c(468): [client 127.0.0.1:37380] 127.0.0.1 - - [localhost/sid#b63dbc90][rid#b663e058/initial] split uri=/api/index.php?/v1/i/login -> uri=/api/index.php, args=/v1/i/login, referer: http://localhost/login.php
[Sun Mar 09 00:07:45.752641 2014] [rewrite:trace2] [pid 10168] mod_rewrite.c(468): [client 127.0.0.1:37380] 127.0.0.1 - - [localhost/sid#b63dbc90][rid#b663e058/initial] [perdir /media/lnendza/Storage/workspace/CheckMate/Heffalump/site/api/] escaped URI in per-dir context for proxy, /api/index.php -> /api/index.php, referer: http://localhost/login.php
[Sun Mar 09 00:07:45.752648 2014] [rewrite:trace2] [pid 10168] mod_rewrite.c(468): [client 127.0.0.1:37380] 127.0.0.1 - - [localhost/sid#b63dbc90][rid#b663e058/initial] [perdir /media/lnendza/Storage/workspace/CheckMate/Heffalump/site/api/] forcing proxy-throughput with http://localhost/api/index.php, referer: http://localhost/login.php
[Sun Mar 09 00:07:45.752653 2014] [rewrite:trace1] [pid 10168] mod_rewrite.c(468): [client 127.0.0.1:37380] 127.0.0.1 - - [localhost/sid#b63dbc90][rid#b663e058/initial] [perdir /media/lnendza/Storage/workspace/CheckMate/Heffalump/site/api/] go-ahead with proxy request proxy:http://localhost/api/index.php?/v1/i/login [OK], referer: http://localhost/login.php
[Sun Mar 09 00:08:08.009404 2014] [rewrite:trace3] [pid 10158] mod_rewrite.c(468): [client 127.0.0.1:37389] 127.0.0.1 - - [localhost/sid#b63dbc90][rid#b6640058/initial] [perdir /media/lnendza/Storage/workspace/CheckMate/Heffalump/site/api/] strip per-dir prefix: /media/lnendza/Storage/workspace/CheckMate/Heffalump/site/api/index.php -> index.php
[Sun Mar 09 00:08:08.009460 2014] [rewrite:trace3] [pid 10158] mod_rewrite.c(468): [client 127.0.0.1:37389] 127.0.0.1 - - [localhost/sid#b63dbc90][rid#b6640058/initial] [perdir /media/lnendza/Storage/workspace/CheckMate/Heffalump/site/api/] applying pattern '^(.*)' to uri 'index.php'
[Sun Mar 09 00:08:08.009473 2014] [rewrite:trace1] [pid 10158] mod_rewrite.c(468): [client 127.0.0.1:37389] 127.0.0.1 - - [localhost/sid#b63dbc90][rid#b6640058/initial] [perdir /media/lnendza/Storage/workspace/CheckMate/Heffalump/site/api/] pass through /media/lnendza/Storage/workspace/CheckMate/Heffalump/site/api/index.php

From the logs, everything looks like it should be working. When I take the URL it spits back (http://localhost/api/index.php?/v1/i/login) and put that into my browser, I can proceed as normal. I hope this helps further diagnose my issue.

LNendza
  • 111
  • 4
  • 2
    First, that doesn't look like something that needs to be in a `.htaccess` file, see [here](http://httpd.apache.org/docs/current/howto/htaccess.html#when). For the 404, there should be entries in your Apache error log - if not, turn up the `RewriteLogLevel` and set a `RewriteLog`. – Shane Madden Mar 07 '14 at 04:26
  • @ShaneMadden: Updated with the write logs. – LNendza Mar 09 '14 at 05:20
  • @LNendza Is there any reason you have it configured to proxy? Should not be needed for local content. – Shane Madden Mar 09 '14 at 06:24
  • @ShaneMadden I don't know truthfully. This is code from a client I'm doing work for and it's how the lead developer has it set up, I haven't had a chance to talk about it in depth with him yet. Either way, thank you for your advice. – LNendza Mar 10 '14 at 02:46

1 Answers1

0

After reading through a bit more about the configuration options it looks like my problem stemmed from not having mod_proxy set in Apache. After enabling it, I was able to move on. This may seem like a small oversight on my part but hopefully this will help somebody in the future.

LNendza
  • 111
  • 4