Welcome Guest, Not a member yet? Register   Sign In
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

(This post was last modified: 06-09-2016, 03:24 AM by pdthinh.)

(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
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




Theme © iAndrew 2016 - Forum software by © MyBB