But today in the use of CI, but forgot, did not come out for a long time, on the CI of China's official network, finally in their help to 觖 the problem, here it posted, for everyone to share.
(Note: I am here to hide the URL of the index.php file, and do not hide different, but ultimately are using absolute URL)
First, I set up in the. htaccess file (the role is to hide index.php), as follows:
Rewriteengine on
Rewritecond $!^ (index\.php|images|js|img|css|robots\.txt) #在这里写要排除的资源等
Rewriterule ^ (. *) $ index.php/$1 [L]
I put the Js,css,img folder and the system folder at the same level, and then in the JS folder to create ajax.js files, I in the view layer of the file for index.html. So I want to introduce JS, as follows:
<script type= "Text/javascript" src= "Url/js/ajax.js '?>" ></SCRIPT>: note Here URL is the absolute URL of your site (absolute URL, is http:// Domain/js/ajax.js This is called an absolute URL)
It's okay to be here. Of course, for maintainability, you can also use the CI base_url to set, as follows:
Enter the application\config\config.php file and set the Base_url in the config.php file:
$config [' base_url '] = http://www.exiplode/com; This is your site root directory.
Set it up and controller somewhere.
$this->load->helper (' url '),
And then in the view layer of the specific page can be introduced:
<script type= "Text/javascript" Src= ' <?=base_url (). ' Js/ajax.js '?> ' ></script>
Well, the introduction of CI in the external JS and CSS is so simple, if there are any problems to communicate with me qq:944597216
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.