I've been working in a local dev environment for some time now with Codeigniter v1.7.1, and I recently installed xampp to replace it. Before, I had modified my hosts file and added a the virtualhost in my httpd.conf file, and my website was running at dev.mysite.com.
After installing xampp, the html is displaying when I go to the url开发者_如何学Python localhost/mysite, however, none of the paths are working correctly, because they are formatted relative to the site root, which apparently is not being set correctly.
For instance:
<script type="text/javascript" src="/public_scripts/homepage.js"></script>
I went into config.php and changed the base_url to a number of different things, such as mysite/, but nothing worked.
What can I do to get CI to use localhost/mysite as the root, so that relative paths formatted like /public_scripts/script.js use mysite as the base url and not localhost?
Thanks!
In your hosts file (C:\WINDOWS\system32\drivers\etc\hosts) add
127.0.0.1 dev.mysite.com
In your virtual host file for that site check the DocumentRoot has 'mysite' in it c:\xampp\apache\conf\extra\mysite.com.conf
DocumentRoot C:/path_to_my_website/site/www/htdocs/mysite/
Are you using the base_url in your views?
<script type="text/javascript" src="<?=base_url()?>public_scripts/homepage.js"></script>
This is just about your /etc/hosts and xampp httpd conf file - you must set up mapping 127.0.0.1 dev.mysite.local or whatever the local domain should be and then add virtualhost like you did before, no way to do this in CI or .htacces.
精彩评论