Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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:

  1. Removing everything from htaccess still accesses the index.php file (probably default behaviour to look for index.php)
  2. I changed the name of index file so that there was no file named index in the application root directory - it threw a 403 .
  3. If I comment out RewriteCond %{REQUEST_FILENAME} !-d it throws a 404
  4. Deny from all throws a 403 as expected
  5. 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

  1. htaccess file
  2. Virtual Host /Directory configuration in httpd conf
  3. 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 .

share|improve this question

migrated from superuser.com Jan 17 '13 at 12:47

This question came from our site for computer enthusiasts and power users.

    
To further my case , there seems to be a number of Old questions around the same issue : stackoverflow.com/questions/4582310/… I have gone through the wiki(s) present on SO regarding this but nothing seems to help . –  Varun Jain Jan 17 '13 at 12:40
    
I think this would be a better fit at webmasters.SE. –  Michael Hampton Jan 17 '13 at 17:49
add comment

1 Answer 1

Was finally able to resolve this . The issue is very specific if you are hosting on a VPS along with cpanel or something similar where your files are not in apache's htdocs folder .

The last line of .htaccess should read :

RewriteRule . /~cpanel_account_name/app_folder/index.php 

This helped out a lot : http://htaccess.madewithlove.be/

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.