Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

At the moment I have my test server set-up like so http://localhost/~callum but I want to set-up a fake url so I can link javascripts and CSS files from my PHP files. Hope this makes sense any help is much a appreciated. I should also say I am using a public_html folder and not var/www.

EDIT: What I mean by fake url is that I want to turn my url from http://localhost/~callum to something like this http://callumstestwebsite.com/ without owning the domain so that I can continue to develop on my new laptop, I used to use windows 7 so I am getting used to ubuntu.

share|improve this question
    
What do you think a 'fake' URL would look like? –  Andrew Lott Sep 25 '13 at 7:50
    
Presumably you want to setup a URL like http://example.com in local DNS? –  w3d Sep 25 '13 at 7:58
    
What I mean by 'fake_url' is that I want to turn my domain to something like www.callumstestwebsite.com/ instead of localhost/~callum so that I can link my css and JavaScript files. Sorry for not posting sooner I was at school. –  Callum Sep 25 '13 at 14:20

1 Answer 1

up vote 2 down vote accepted

To be able to access a local resource as if it were the main site you need to do two things:

  1. Edit your hosts file such that your computer thinks that your domain name is served by localhost. Your hosts file should contain a line with 127.0.0.1 in it and your host name would need to be added to that line, something like: 127.0.0.1 localhost callumstestwebsite.com Use the command line sudo editor /etc/hosts to edit this file.

  2. Configure your webserver to serve the website when a request is made for that host name. It appears that you are currently serving the site only when there is a path of /~callum but you would need to configure the webserver differently. Generally this would entail adding a virtualhost directive something like (for apache server in httpd.conf):


<VirtualHost *:80>
    DocumentRoot /home/callum/public_html
    ServerName callumstestwebsite.com
</VirtualHost>

In my Debian based distribution I would create a file called /etc/apache2/sites-available/callumstestwebsite with that contents (and any other needed configuration), then enable the site with the command: sudo a2ensite callumstestwebsite, then restart my webserver with sudo service apache2 restart

share|improve this answer
    
Thank you, that is what I meant. Sorry for those who posted earlier I was still half a sleep before I went to school. –  Callum Sep 25 '13 at 14:35
    
if possible could you give me the command lines? –  Callum Sep 25 '13 at 15:00
    
I've added several command lines that I would use for my distribution (Ubuntu, debian based). Different distributions do apache configuration differently, so your milage may vary. –  Stephen Ostermiller Sep 25 '13 at 15:08
    
thank you for the help. –  Callum Sep 25 '13 at 15:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.