Help with virtual hosting required..

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

Help with virtual hosting required..

Postby compass1312 » 01. July 2014 01:36

Hi guys, I cannot get my head around setting up virtual hosting in xampp. I have entered the following codes as suggested by numerous tutorials. The server seems to find the index.html, but does not render it properly. i.e cannot find the css file, and gives a 404 error for links. Can somebody please explain what I am doing wrong?

TIA


c:\windows\system32\driver\etc\hosts

# 127.0.0.1 localhost

# ::1 localhost
127.0.0.1 truvotes.localhost


httpd-vhosts.conf

<VirtualHost *:80>
DocumentRoot c:/xampp/htdocs
ServerName localhost
</VirtualHost>

<VirtualHost *:80>
DocumentRoot c:/xampp/htdocs/truvotes
ServerName truvotes.localhost
<Directory "C:/xampp/htdocs/truvotes">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
compass1312
 
Posts: 7
Joined: 29. June 2014 01:14
Operating System: Win7 32 bit

Re: Help with virtual hosting required..

Postby Altrea » 01. July 2014 08:58

This is a application configuration issue.
XAMPP components don't generate any css or application links
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11926
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: Help with virtual hosting required..

Postby DigitalArtwork » 01. July 2014 15:06

Yeah that answer was usefull...

Forget httpd-vhosts.conf... I did it this way:

host file:
127.0.0.1 dev.sitename
# where dev is my development site
127.0.0.1 preprod.sitename
# where prepod is my preproduction site
127.0.01. dev.othersitename

httpd.conf file
Add this to the bottom of your file

NameVirtualHost 127.0.0.1

<VirtualHost 127.0.0.1>
ServerName dev.sitename
DocumentRoot "C:/websites/sitename"
<Directory "C:/websites/sitename">
Options Indexes Includes execCGI
AllowOverride All
Order Allow,Deny
Allow From All
# Allow From All gives you the possibility to use .htaccess file
</Directory>
</VirtualHost>

# repeat the virualhost section for each site you are running

Hope this helps...
DigitalArtwork
 
Posts: 1
Joined: 01. July 2014 14:57
Operating System: Windows

Re: Help with virtual hosting required..

Postby Altrea » 01. July 2014 15:25

DigitalArtwork wrote:Yeah that answer was usefull...

More useful than your "solution" because you don't know what you are doing.

DigitalArtwork wrote:Forget httpd-vhosts.conf... I did it this way:
[...]
httpd.conf file
Add this to the bottom of your file

It is independend in which of these two files you are doing the vhost definition. httpd-vhosts.conf gets included inside httpd.conf

DigitalArtwork wrote:NameVirtualHost 127.0.0.1

NameVirtualHost Definition is obsolet with Apache 2.4 and will produce a Notice in your log

DigitalArtwork wrote:<VirtualHost 127.0.0.1>

Matching on all possible ports of one single ip is rarely senseful.
Very common services on other ports like "ssl", "dav", etc need additional definitions.
So unless you are listening on different ports for http requests it is not useful.
Better use <VirtualHost *:80>

DigitalArtwork wrote: Order Allow,Deny
Allow From All

This is old access syntax and only functional for Apache 2.4 through a compatibility module.
If the new Syntax is already used in prior definitions you will not override it with this definitions so you will very common get an http status error 403 anyway.

DigitalArtwork wrote: # Allow From All gives you the possibility to use .htaccess file

This is simply wrong. AllowOverride is defining functionality of htaccess, not Allow from.

DigitalArtwork wrote:Hope this helps...

not really.
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11926
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: Help with virtual hosting required..

Postby compass1312 » 02. July 2014 02:08

So, from the answers, I still have not learned anything useful...

@Altrea: If DigitalArtwork's answer is either wrong or outdated, what is the correct coding? I have looked at many tutorials, and all of them say similar. Maybe they are old. Could you either help or point me in the right direction please. If you are here to be obstructive or evasive, then you should not be moderating this site. The whole saga is taking days instead of minutes. It is not helpful to pick someone's answer to bits without giving the correct one. Now, if you know the answer to my question, please give it. If not, say so...

Thanks DigitalArtwork for your answer. I will give it a go whilst waiting for Altrea...

TIA
compass1312
 
Posts: 7
Joined: 29. June 2014 01:14
Operating System: Win7 32 bit

Re: Help with virtual hosting required..

Postby Altrea » 02. July 2014 05:29

compass1312 wrote:@Altrea: If DigitalArtwork's answer is either wrong or outdated, what is the correct coding?

The correct coding for DigitalArtwork example could be something like this:

C:\windows\system32\drivers\etc\hosts
Code: Select all
127.0.0.1    dev.sitename


\xampp\apache\conf\extra\httpd-vhosts.conf
Code: Select all
# vhost for http://localhost
<VirtualHost *:80>
    ServerName localhost
    DocumentRoot "C:/xampp/htdocs"
</VirtualHost>

# vhost for http://dev.sitename
<VirtualHost *:80>
    ServerName dev.sitename
    DocumentRoot "C:/websites/sitename"
    <Directory "C:/websites/sitename">
        Options Indexes FollowSymLinks Includes ExecCGI
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>


But again:
This will not solve your issue, because your issue is an application configuration issue.
I am guessing that your application has something like an url builder which is building wrong urls because it is configured wrong (base url or any similar setting).
XAMPP components are not involved by buildung asset urls for css files and similar.

So: i have already told your the answer, but you don't want to hear it.
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11926
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: Help with virtual hosting required..

Postby Nobbie » 02. July 2014 10:47

compass1312 wrote:So, from the answers, I still have not learned anything useful...


I will give it a try:

Youre Xampp configuration is NOT the reason for the error 404. You will not change anything on this error by changing Xampp. THERE IS AN ERROR IN YOUR APPLICATION (whatever application you are running, you did not tell us).

Got it now?
Nobbie
 
Posts: 13170
Joined: 09. March 2008 13:04

Re: Help with virtual hosting required..

Postby compass1312 » 03. July 2014 05:31

Solved...
It seems there was nothing wrong with the config files. All I did was move the whole folder from htdocs/website into a top tier folder c:\website and it worked. Something to do with permissions I believe.
The only thing that didn't work was SSI, which I still have to figure out.

Once I found the answer, it was only a matter of minutes to adjust. Now if anyone would care to help me set permissions for SSI, I would be appreciative.

And thanks for your help...
compass1312
 
Posts: 7
Joined: 29. June 2014 01:14
Operating System: Win7 32 bit

Re: Help with virtual hosting required..

Postby Altrea » 03. July 2014 06:12

compass1312 wrote:Something to do with permissions I believe.

Still: No. Missing file permissions would result in HTTP status code 403 not 404. It is an application issue.
I'm tired to repeat myself. Seems you don't want to hear the truth. I am out here.
Maybe someone else is motivated to help you out.
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11926
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 120 guests