• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I cant include js files

#1
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 ?
Reply

#2
(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
Reply

#3
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]
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#4
Try Moving the js path to the following:


var/www/js/ajaxGetRegions.js
download and make your system directory strict
Reply

#5
Server could be case sensitive also, try changing the name to all lower case.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.