CodeIgniter Forums
I cant include js files - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: I cant include js files (/showthread.php?tid=65414)



I cant include js files - isengart - 06-09-2016

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 ?


RE: I cant include js files - pdthinh - 06-09-2016

(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


RE: I cant include js files - InsiteFX - 06-09-2016

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]



RE: I cant include js files - John_Betong - 06-09-2016

Try Moving the js path to the following:


var/www/js/ajaxGetRegions.js


RE: I cant include js files - InsiteFX - 06-10-2016

Server could be case sensitive also, try changing the name to all lower case.