PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, February 18, 2022

[FIXED] CodeIgniter include js,css files from application returns 403 forbidden

 February 18, 2022     apache, codeigniter, mamp     No comments   

Issue

I am having a problem loading a javascript or css or any other file from inside the application/modules directory.

I am using MAMP and CodeIgniter with HMVC and trying to have a js and css folders inside a module folder. Then when I am calling the controller methods I am also loading the asset files.

I have other sites that are working in that way. The structures are the same and the CodeIgniter versions are the same. Basically I have copied the previous website and started from there.

But it always returns 403 forbidden.

What I did but still nothing changes:

  1. the whole site directory is writable and readable.
  2. I can create and read new files from PHP to that dir
  3. I have htaccess file which I tried to remove or change
  4. Reinstalled MAMP
  5. Tried to open a simple html file
  6. The MAMP user and group has full access to the dir
  7. I tried to run the website on another server

The apache log says "[Tue May 22 17:24:30 2012] [error] [client 127.0.0.1] client denied by server configuration"

Here is the .htaccess file:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php/$1 [L]

At the same time everything is fine with the other site.

I have spent many hours so far and I am stuck.

Any thoughts or suggestions are appreciated.

Thanks,


Solution

CodeIgniter comes with a .htaccess in the /application directory which contains

Deny from all

You'll need to remove this file or change it's ruleset to access js/css files etc from anywhere inside application/*

It is however largely inadvisable to allow access entirely to the application, it's perhaps best to modify this .htaccess file to allow access to application/modules/*/css|js/



Answered By - Ben Swinburne
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing