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!
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.
Related
I am a total noob at this. Got MAMP, Laravel. My webroot is /Applications/MAMP/htdocs. Normally to hit my laravel application I have to go to:
http://localhost:8080/myapp/public/index.php
What files do I have to configure to be able to access it like this:
http://myapp.com/index.php
I've read docs about adding an entry into my hosts file but when I tried adding the following entry 127.0.0.1 myapp.com I still have to do http://myapp.com/myapp/public/index.php.
What am I missing?
You need to edit your .htdocs file to forward myapp.com to 127.0.0.1 and then set up a DocumentRoot in your httpd.conf file. You can set up multiple redirects if you do it properly.
I've recently got a VPS server and it came installed with CentOS, WHM and cPanel. I'm trying to find where the physical folder location the root URL of the server IP is being served. When I go to the root IP in a browser, I get a redirect to "/cgi-sys/defaultwebpage.cgi" with "SORRY!" and some error resolve details.
The server has a web-site running under "/cPanel" and also WHM runs on ":2083".
I'm trying take control of the content served directly at the /, and replace that defaultwebpage.cgi with an index.html.
I've tried httpd -V to check where the httpd.conf, is and then spotted a <VirtualHost *> in that config file, which points to a DocumentRoot of /use/local/apache/htdocs . But if I place index.html in this folder and try to hit it via /index.html, I still get routed to that defaultwebpage.cgi. Can anyone help me understand why its rerouting and not picking up that index.html?
Thanks.
You may want to try /var/www/html, at least that's in Ubuntu
If it's not it, then try going to /etc/apache2/apache2.conf and find the DocumentRoot option.
Hope this helps!
I am running XAMPP 1.8.2
Inside of htdocs folder I have a several sites.
Now I downloaded a working website from my hosting/server and found out that the identical copy of that website run on Xampp [http://localhost/mysite] can not find the images.
It is looking for images on
[http://localhost/img/myimage01.jpg] instead of
[http://localhost/mysite/img/myimage01.jpg]
I read some solutions but they all come to pointing the whole thing to [http://localhost/mydomain]
I would prefer if I can tell XAMPP to look for files for every domain from it's own root directory.
How can I do this?
Thanks
The easiest way is to create separate virtual host for each site folder in /htdocs
So you will access the http://mysite.local instead http:// localhost/mysite
There are two things to do:
1. edit C:\xampp\apache\conf\extra\httpd-vhosts.conf (by default) adding something like
<VirtualHost *:80>
ServerName mysite.local
DocumentRoot C:/XAMPP/htdocs/mysite
</VirtualHost>
2. edit c:\windows\system32\drivers\etc\hosts adding
127.0.0.1 mysite.local
restart xampp and try http://mysite.local
You generally can't move a whole website from http://<somedomain> to http://<somedomain>/<somefolder>. Things are bound to go wrong with links between pages in the site and links within pages to images.
Let's say you are displaying images within HTML web pages using image tags like this:
<img src="img/myimage01.jpg"></img>
This will probably work as the browser will look for the img folder in the same folder as the web-page.
On the other hand if your image tag looks like this (note the extra /) you will have the problem you describe:
<img src="/img/myimage01.jpg"></img>
The extra / means the browser will look for the img folder at the root of the domain.
What would be the best way to set up XAMPP so that when I go to
http://localhost1 it access the folder C:\localhost1
and when I type
http://localhost2 it access the folder C:\localhost2?
I've done a response yesterday that should fit your needs:
Modify htaccess file for two sites
Use Alias in apache conf
http://www.apachefriends.org/f/viewtopic.php?f=16&t=36801
Make XAMPP/Apache serve file outside of htdocs
I have installed Apache on my local machine (Windows 7, using AppServ).
I opened a library called "MySite" under AppServ directory, so to access it I use the following URL:
http://127.0.0.1/MySite
The problem is that when I use
<link type='text/css' href='/stylesheets/main.css' rel='stylesheet' media='all' />
The file is not loaded since it tries to look it in http://127.0.0.1/ instead of http://127.0.0.1/MySite .
How can I change this?
Thanksm
Joel
Edit your apache.conf File and set your DocumentRoot to MySite
Actually, your question shows a flaw in your setup:
You want http://127.0.0.1/MySite to point to a certain directory, say /var/www/MySite.
This implies that
http://127.0.0.1/ points to /var/www/, and that
http://127.0.0.1/stylesheets points to /var/www/stylesheets.
But you want http://127.0.0.1/stylesheets to point to a subdirectory, say /var/www/MySite/stylesheets.
It's possible, but probably not very wise.
Workarounds:
Add an Alias for /stylesheets to /var/www/MySite/stylesheets
Set the DocumentRoot to /var/www/MySite and access the site with http://127.0.0.1
vhosts
Rewrite rules
You could change documentRoot:
http://httpd.apache.org/docs/2.0/mod/core.html#documentroot