2

I'm having a hard time with .htaccess directive. I'm trying to have URL rewriting for Codeigniter framework.

Everything works as expected on the production server but I'm not able to properly set up my own testing server.

Testing server

URL rewriting works great, php files are rendered as expected, but all files included via HTML (css, js, img) are not displayed as they are not accessible due to:

403 Forbidden
You don't have permission to access /path/to/file/plugins-min.css
on this server.

Here is my .htaccess file:

RewriteEngine On

# Do not enable rewriting for files or directories that exist
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# For requests that are not actual files or directories,
# Rewrite to index.php/URL
RewriteRule ^(.*)$ index.php/$1 [PT,L]

This is the Apache2 configuration for my document folder:

<Directory /document/folder/>
    Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
    AllowOverride All
    Order deny,allow
    Allow from all
</Directory>

When I set AllowOverride to None (i.e. not rewriting URLs) then static files are correctly shown.

When images are uploaded via script they are shown on the page even if they have the same permissions/owners/groups as the other files which are not accessible.

Everything has the same permissions and owners on the site.

I think my Apache configuration has something which prevents the 'included HTML' files from being accessible, as the Apache error log says:

[Wed Aug 17 22:29:24 2011] [error] [client <MY IP>] client denied by server
configuration: /var/www/site.com/application/assets/js/admin.js, 
referer: http://<MY IP>/site.com/page/edit/

Thanks in advance

3
  • 2
    Is it possible you have another .htaccess somewhere in the path that is causing grief?
    – polynomial
    Aug 25, 2011 at 18:18
  • 1
    @polynomial: I did look better to my folders and actually there where .htaccess files bothering out there. If you post an answer you'll get the bounty!
    – Dalen
    Aug 28, 2011 at 13:50
  • cool glad that helped!
    – polynomial
    Aug 28, 2011 at 14:05

3 Answers 3

2
+50

It is really common when using AllowOverride All to find .htaccess files in other directories above where you are working that impact your configuration. Per the comment thread posting this answer to collect the bounty. Here is an example find command:

find DocumentRoot -name .htacccess -print

Will print any other .htaccess files.

1

Find all the .htaccess files with:

find /var/www/ -name .htaccess

As a temporary, change:

Order deny,allow
Allow from all

to:

Order allow,deny
Allow from all

to ensure that there is no Deny rules processed before.

0

Add following rules to Apache configuration inside section:

Allow from 127.0.0.1
Allow from localhost
1
  • Hi @Reza, I did try your soluton but it did't solved the issued. Allow from Alldoesn't already include loopback and localhost?
    – Dalen
    Aug 27, 2011 at 22:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .