CodeIgniter Forums

Full Version: I cant include js files
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello, first time using CI and seems awesome!
Im trying to include a js file and doesnt seem to work.

Im getting 404 error not found.

View File:

PHP Code:
<script type="text/javascript" src="<?php echo base_url();?>js/ajaxGetRegions.js" ></script

My js path:

var/www/applications/js/ajaxGetRegions.js


.htaccess

PHP Code:
RewriteEngine On
RewriteCond 
%{REQUEST_FILENAME} !-f
RewriteCond 
%{REQUEST_FILENAME} !-d
RewriteCond 
$!^(index\.php|images|js|robots\.txt)
RewriteRule ^(.*)$ index.php [L,QSA

Seems that the problem is the .htaccess I used to remove the index.php, altough i try to exclude the js folder from that.

mod_rewrite is enabled.

Any ideas what could be the issue ?
(06-09-2016, 12:54 AM)isengart Wrote: [ -> ]Hello, first time using CI and seems awesome!
Im trying to include a js file and doesnt seem to work.

Im getting 404 error not found.

View File:

PHP Code:
<script type="text/javascript" src="<?php echo base_url();?>js/ajaxGetRegions.js" ></script

My js path:

var/www/applications/js/ajaxGetRegions.js


.htaccess

PHP Code:
RewriteEngine On
RewriteCond 
%{REQUEST_FILENAME} !-f
RewriteCond 
%{REQUEST_FILENAME} !-d
RewriteCond 
$!^(index\.php|images|js|robots\.txt)
RewriteRule ^(.*)$ index.php [L,QSA

Seems that the problem is the .htaccess I used to remove the index.php, altough i try to exclude the js folder from that.

mod_rewrite is enabled.

Any ideas what could be the issue ?

Resource files (images, javascripts, stylesheets...) should be placed in a public folder, usually same folder with index.php
Remove this line in your .htaccess file you do not need it and it will cause problems!

Code:
RewriteCond $1 !^(index\.php|images|js|robots\.txt)

Also change to this:

Code:
RewriteRule ^(.*)$ index.php/$1 [QSA,L]
#or this
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
Try Moving the js path to the following:


var/www/js/ajaxGetRegions.js
Server could be case sensitive also, try changing the name to all lower case.