Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
A donation makes a contribution towards the costs, the time and effort that's going in this site and building.
Thank You! Steffen
Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
| |
|
Topic: Rewriting the domain part of a URL, locally hosted sandbox |
|
Author |
|
KenBarlow
Joined: 05 Jan 2012 Posts: 2
|
Posted: Thu 05 Jan '12 21:22 Post subject: Rewriting the domain part of a URL, locally hosted sandbox |
|
|
I have a web site that is written and hosted on a public server, lets say it is www.mysite.com. I have installed a local copy of Apache on my laptop, not connected to the outside world. Setting htdocs allows me to view the web site from my local file system, lets say from file:///c:/tempdir.
Links in the locally hosted web site work fine when they link to a relative path, but some links use the full URL and I want to configure .htaccess file so I can also view html pages with these absolute http://www.mysite.com/foo.html paths. I have tried numerous attempts at this using regular expressions in rewrite rules, but have not got it to work, and don't think it is the right way of re-writing the domain part of the URL.
In essense, I want URLs such as http://www.mysite.com/afile.html to be served from file:///c:/tempdir/afile.html.
I would be grateful for any assistance in achieving this.
Thanks in advance! |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7371 Location: Germany, Next to Hamburg
|
Posted: Fri 06 Jan '12 16:08 Post subject: |
|
|
If you are using apache, just put all the files into the htdocs folder or make C:\tempdir your documentroot and open http://localhost/afile.html |
|
Back to top |
|
KenBarlow
Joined: 05 Jan 2012 Posts: 2
|
Posted: Fri 06 Jan '12 16:17 Post subject: |
|
|
Yes, that is what I have done, but does not answer my question because it does not redirect an explicit http URL with file name to a file URL with the same relative file name.
I was looking at if this could be done using a hosts file. |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7371 Location: Germany, Next to Hamburg
|
Posted: Fri 06 Jan '12 16:25 Post subject: |
|
|
Yepp, you can.
in the end of your hosts file of the laptop add
Has the side effect that will always reach the laptop itself when you type into your browser, even when it is connected to the internet.
Search for ServerName in the httpd.conf and put there your www.mysite.com
Put all your files into the apache htdocs folder
restart apache
than it will be same behaviour like on your server in the internet. |
|
Back to top |
|
|
|
|
|
|