skiindude22
skiindude22

Reputation: 509

Codeigniter basepath issue on xampp

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 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>
is pointing toward the URL localhost/public_scripts rather than localhost/mysite/public_scripts.

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!

Upvotes: 0

Views: 2313

Answers (3)

Mitchell McKenna
Mitchell McKenna

Reputation: 2276

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/

Upvotes: 1

Jarek Tkaczyk
Jarek Tkaczyk

Reputation: 81167

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.

Upvotes: 0

Sander Bakkum
Sander Bakkum

Reputation: 421

Are you using the base_url in your views?

<script type="text/javascript" src="<?=base_url()?>public_scripts/homepage.js"></script>

Upvotes: 0

Related Questions