CodeIgniter Forums
link js file in view folder - 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: link js file in view folder (/showthread.php?tid=63280)



link js file in view folder - seasenx6 - 10-15-2015

IF I have js file in view folder.

And I want to know how to link js file from js file in VIEW FOLDER.

thank you.


RE: link js file in view folder - Martin7483 - 10-15-2015

You can't do that. View directories are not available through a request URI.
So the URL for the JS file must be callable via the browser.
E.g. http://www.yourdomain.com/assets/js/your-file.js

You can use an assets directory where you store al JS/CSS and images required for use in your views.
If you are using a htaccess file to remove the index.php from your URL you can add assets to the condition so that asset urls are not routed through the index.php
Code:
#Rule for routing all page requests through index.php
RewriteCond $1 !^(index\.php|assets|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]