How to alias from xampp/htdocs to local file://structure/../

Problems with the Windows version of XAMPP, questions, comments, and anything related.

How to alias from xampp/htdocs to local file://structure/../

Postby educmale » 30. July 2012 15:19

I have installed XAMPP - Lite on a Win7 Box. I have installed the most recent XAMPP, 1.8

I have, in my local file structure, a folder containing local copies of various websites:
    c:/web/firstdomain
    c:/web/seconddomain

I would like to leave those local files where they are on my local machine, and use XAMPP. That is, to map a request on my local machine, with XAMPP enabled, as follows:
    127.0.0.1/firstdomain/foo.html ---> c:/web/firstdomain/foo.html
    or, more generically: 127.0.0.1/anyDomain/*.* ---> c:/web/anyDomain/*.*

I would have guessed that some version of an .htaccess or .httpd at the root [ie, at ..../xampp/htdocs/.ht...] would accomplish this, but I have tried various forms, and they all render my server confused.

Any suggestions ? Or, is the ONLY solution to move the web folder.... ? A Win7 mapping ?
educmale
 
Posts: 4
Joined: 30. July 2012 14:28
Operating System: Win 7

Re: How to alias from xampp/htdocs to local file://structure

Postby JonB » 30. July 2012 16:36

that's what vhosts are for.

each has its own DocumentRoot - which can be pretty much anywhere (some exceptions) on the local filesystem

there is an example in C:\xampp\apache\conf\extra\httpd-vhosts.conf

reference
http://httpd.apache.org/docs/trunk/vhos ... based.html

ALWAYS make the first vhost a duplicate of your default install - it will act as a -catchall and allow you to continue to access things you may need as an administrator.

The Name VirtualHost directive is now fully obsoleted, so don't remove its comment (or include it if you create your own .conf file)

Good Luck
8)
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7

Re: How to alias from xampp/htdocs to local file://structure

Postby educmale » 30. July 2012 20:55

Thanks, Jon

That helps...though I am now thinking through and realizing that the .htdocs I have on my local copy of my domains, includes redirects, and 404s and on and on, that wouldn't be relevent or correct when testing from my local machine. So I am thinking I need to make a xampp copy , anyway...

But, just in case the vhost helps, these confusions remain:

In reading that: I sense this for the items of higher interest:
    ##<VirtualHost *:80>
    ##DocumentRoot "winFOO/xampp/htdocs/xampp.localhost"
    ##ServerName xampp.localhost
    ##ServerAlias www.xampp.localhost
    ##ErrorLog "logs/xampp.localhost-error.log"
    ##CustomLog "logs/xampp.localhost-access.log" combined
    ##</VirtualHost>

OR is it "winFOO/xamp/htdocs" for the DocRoot?? because that is where I have the files...? I don't get why the xampp.localhost is appended to the DocRoot? Or what I would type in a local browser to land on the local web site.

For the other host, #2: do I use use "winFOO/otherFOO/ . . . . ?? same sort of confusion bubbles in the background.

So, to call up the actual directory from the browser, this is what I might have guessed from the documentation.... to merely type:
1. xampp.localhost for the xampp stuff...
2. foo.localhost for the rest of it ?
but, I'm not sure if I am landing my understanding, correctly. am I supposed to type in only localhost or 127.0.0.1, as I do now ?
educmale
 
Posts: 4
Joined: 30. July 2012 14:28
Operating System: Win 7

Re: How to alias from xampp/htdocs to local file://structure

Postby JonB » 30. July 2012 22:47

I didn't write the example unfortunately. Its a Unix-like terminology there. On a Linux system the base install is known as localhost.localdomain And I now see its an absolutely awful example - it bears no relationship to a Windows XAMPP installation.

This is a working vhosts example...

# duplicate the installed root/default

<VirtualHost *:80>
ServerAdmin johnb@newnetenterprises.com
DocumentRoot "/xampp/htdocs"
ServerName bravo.newnetenterprises.com
##ServerAlias bravo.newnetenterprises.com
ErrorLog "logs/bravo-error.log"
##CustomLog "logs/dummy-host.localhost-access.log" combined
</VirtualHost>

# start the vhosts entries:

<VirtualHost *:80>
ServerAdmin johnb@newnetenterprises.com
DocumentRoot "/xampp/sites/en.newnetenterprises"
ServerName en.newnetenterprises.com
##ServerAlias en.newnetenterprises.com
ErrorLog "logs/en_bravo-error.log"
##CustomLog "logs/dummy-host.localhost-access.log" combined
</VirtualHost>
<VirtualHost *:80>
ServerAdmin johnb@newnetenterprises.com
DocumentRoot "/xampp/sites/es.newnetenterprises"
ServerName es.newnetenterprises.com
##ServerAlias en.newnetenterprises.com
ErrorLog "logs/es_bravo-error.log"
##CustomLog "logs/dummy-host.localhost-access.log" combined
</VirtualHost>
....
I have 4 more in the setup. I just cut & pasted them after I had pattern (as you can tell from the ServerAlias) They are language variants of a series of WordPress CMS's

Note that ServerAlias and CustomLog are optional fields, you will FOR sure want separate error logs.

the DocumentRoots would be folders with pathnames in 'windows drive letter format' if they are outside the ServerRoot.

for instance:
DocumentRoot "/xampp/sites/en.newnetenterprises"
could be
DocumentRoot "e:/sites/en.newnetenterprises" instead

The reason I put my sites (the vhosts files) inside the ServerRoot was simple, I had plenty of disk space, AND by doing that I could run a single daily backup and get all my XAMMP sites and work in one pass. It really does not matter where you put them (don't put them in C:\users -- many many bad things can go wrong that way). However - BE SURE TO BACKUP!

If you want to use domain names for them - particularly if they mirror 'real-world' sites, you would add them to your hosts file. That way DNS will use them exactly as if they were in the real world - but never try to connect to your real servers. You would need to fix outbound calls etc. as well

I have my own DNS and servers, so I 'fix things there', but for those sites (if I only wanted to access them from the machine I was on) - the entries in the hosts file would be

127.0.0.1 bravo.newnetenterprises.com
127.0.0.1 en.newnetenterprises.com
127.0.0.1 es.newnetenterprises.com
...


You should also read that Apache page, as I think its quite clear really - after my last explanation here. I didn't realize what an awful example was given.

Good Luck
8)
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7

Re: How to alias from xampp/htdocs to local file://structure

Postby educmale » 31. July 2012 20:23

Jon: Very helpful...thanks.. Ive been into the Apache Doc on VHosts, and will revisit them in a while with your gloss in hand.

Currently, after setting up the xampp:

The local machine has content, at xampp/htdocs/foo, which I access in the browser, now, as localhost/foo -- that is fine for me. If i want to go to my real site, i go there, as www.foo.com. I considered toying with the Local Hosts, but didn't want to force all calls to foo.com to go locally, to xampp.

The downside is that the xampp/foo is, effectively, a copy of the local copy of the Live version. The non-xampp copy includes the .htaccess and etc that the ISP allows me to use, which causes confusion on my xampp/foo copy, so I had to strip it.

I see that I can create multiple hosts, locally with your guide, but with me typing localhost/fooOne or localhost/fooTwo, i get the local copy comfortably.

I suppose . . . a perfect world would allow me to use the ISP/Mirror/copy, as stashed on my local, without getting twisted with the .htaccess. I would use FileZilla to up/down mirror images, as I make changes, to that same copy. I could test the site, locally, making changes locally.

And, I recognize, now, that I could do that for one+ domains with VHosting, and mods to the .httpd. My early play with xampp/Apache, and .httpd, to mod the pointer to the local mirror web site got tangled; part of that tangle that led to my seeking guidance here -- part .htaccess/redirect issues and part confusion. Looks like...for the moment...that I will have to keep a local mirror and a local xampp/copy; or figure a way to use my xampp .htdocs, and redirect other content from xampp/fooOne, over to c:/Fooishness/fooOne -- using C:?

And, as it stands, now, I don't get what's wrong with the User tree? I have no problems not using it. I thought that xampp would be happier not on the root, for some reason. Now...it's dropped on the desktop, a User tree derivative.

Anyway...thanks for the guide. More play ahead

john
educmale
 
Posts: 4
Joined: 30. July 2012 14:28
Operating System: Win 7

Re: How to alias from xampp/htdocs to local file://structure

Postby JonB » 31. July 2012 21:54

The 'user' tree can run into issues. If you have services installed, and you boot the machine but do not login, there will not be an authenticated user.

Everywhere XAMPP has advsories/tutorials - they tell you (me included) PUT IT IN THE ROOT.

FOR SURE - never in Program Files.

Remember - 'foo' goes with 'bar'

Good Luck
8)
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7

Re: How to alias from xampp/htdocs to local file://structure

Postby educmale » 31. July 2012 22:17

I had discovered the angst of XAMPP in the win7 program files, with access permission run amuck. I landed on my desktop for convenience, and generally I avoid services. I had WAMP'd on another machine, again to the desktop, a cpl of years ago.

but...
I will reinstall, now, to the root...!

"I've never known a good English writer to turn down bar foo'd, but they can live distinct lives..."
educmale
 
Posts: 4
Joined: 30. July 2012 14:28
Operating System: Win 7

Re: How to alias from xampp/htdocs to local file://structure

Postby JonB » 02. August 2012 16:19

very punny

:lol:
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 52 guests