I have an application set up on Apache 2.2 CentOS (with cPanel). I am facing issues with htaccess. I have confirmed that mod_rewrite is working. My .htaccess file is laid out like :
RewriteEngine on
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php
My webapp folder basically has a file index.php , all URL requests need to be directed through this file.
I tried the following and it seems my .htaccess or httpconf has issues:
- Removing everything from htaccess still accesses the index.php file (probably default behaviour to look for index.php)
- I changed the name of index file so that there was no file named index in the application root directory - it threw a 403 .
- If I comment out
RewriteCond %{REQUEST_FILENAME} !-d
it throws a 404 Deny from all
throws a 403 as expected- With this configuration all other directories (such as those containing CSS/images etc) which do not have their individual htaccess throw a 403 when I try to access them
Possible problem areas
- htaccess file
- Virtual Host /Directory configuration in httpd conf
- Apache User Permission issues on folders(not likely)
What might be the way to figure out what's going wrong and how do I correct it?
EDIT
I looked at the server error_log and this is what I found :
[Thu Jan 17 07:44:45 2013] [error] [client 182.68.43.96] File does not exist: /usr/local/apache/htdocs/home
[Thu Jan 17 07:44:45 2013][error] [client 182.68.43.96] File does not exist: /usr/local/apache/htdocs/home, referer: http://IP_ADDRESS_HERE/~myapp/myapp/user
It is looking for the files in apache htdocs when it is present in an alternate directory . Even so , it should not be looking for a directory called 'user' under myapp , it should be redirected to index.php as per htaccess file . I re wrote the base , now it is looking under the myapp directory , however it still does not execute index.php as it should at every request .