logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

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.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Rewriting the domain part of a URL, locally hosted sandbox
Author
KenBarlow



Joined: 05 Jan 2012
Posts: 2

PostPosted: Thu 05 Jan '12 21:22    Post subject: Rewriting the domain part of a URL, locally hosted sandbox Reply with quote

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

PostPosted: Fri 06 Jan '12 16:08    Post subject: Reply with quote

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

PostPosted: Fri 06 Jan '12 16:17    Post subject: Reply with quote

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

PostPosted: Fri 06 Jan '12 16:25    Post subject: Reply with quote

Yepp, you can.

in the end of your hosts file of the laptop add
Code:

127.0.0.1 www.mysite.com


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


Reply to topic   Topic: Rewriting the domain part of a URL, locally hosted sandbox View previous topic :: View next topic
Post new topic   Forum Index -> Apache