Matt Ellis Matt Ellis - 1 year ago 79
PHP Question

PHP/CodeIgniter file url - Forbidden Error

I am a PHP/CodeIgniter newbie and am asking for some guidance on file structure.

Here is what's happening --> When I try to access a file (mp4 or pdf) by just entering the url into the address bar for my localhost, I am receiving a "Forbidden error" -- but no error when I access a jpeg file in the same directory.



Forbidden Error in same directory:


Although this does work for the mp4 and pdf file:


I need to be able access the mp4 and pdf files for the application, but not sure why the error - any help would be greatly appreciated, thanks.

.htaccess file in web folder:

#Header set X-Robots-Tag "index"

RewriteEngine on

#RewriteCond %{HTTP_HOST} !^$
#RewriteRule (.*)$1 [R=301,L]

RewriteCond $1 !^(index\.php|assets|uploads|wp|robots\.txt)
RewriteRule ^(.*)$ /index.php?/$1 [L]

php_value max_input_time 600
php_value post_max_size 1000M
php_value upload_max_filesize 1000M
php_value max_execution_time 6000000

.htaccess file in uploads folder:

Order deny,allow
Deny from all
<Files ~ ".(jpe?g|png|gif)$">
Allow from all

Answer Source

check the file permission on your files /uploads/_intro.mp4 and /uploads/test.pdf, they should be readable by your web server in order to be served as web files.

your try running this on command line:

$ cd /Users/mattellis/_projects/test-projects/test/web
$ chmod +r ./uploads/*


if above didnt work, update the /Users/mattellis/_projects/test-projects/test/web/uploads/.htaccess file to:

Order deny,allow
Deny from all
<Files ~ ".(jpe?g|png|gif|mp4|pdf)$">
Allow from all
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download