0

Looking for some help with setting up a subdomain in XAMPP.

I've read a few articles, whilst they seem to be all related to local installs, what I have is a PORTABLE version of XAMPP so there is no drive prefix.

I tried some of the mentioned articles below but none seem to work. They all display a server not responding or end up going to google to search.

I have in httpd.conf

# Virtual hosts
Include conf/extra/httpd-vhosts.conf

Then in extra/httpd-vhosts.conf

NameVirtualHost *:80

<VirtualHost *>
    ServerAdmin admin@localhost.com
    ServerName localhost
    ServerAlias localhost
    DocumentRoot "/xampp/htdocs/public"
    <Directory "/xampp/htdocs/public">
        Options Indexes FollowSymLinks Includes ExecCGI
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

<VirtualHost forums*>
    ServerAdmin admin@localhost.com
    ServerName forums
    ServerAlias forums
    DocumentRoot "/xampp/htdocs/public/forums"
    <Directory "/xampp/htdocs/public/forums">
        Options Indexes FollowSymLinks Includes ExecCGI
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

When I do this "forums.localhost" is turns into this in chrome "http://www.forums.localhost/" and then I get:

The webpage is not available

Amongst many I have read, some mention editing windows hosts file, but given this is a PORTABLE version of XAMPP I can't always go editing the hosts file in every computer.

these were few I tried but they all fail http://austin.passy.co/2012/setting-up-virtual-hosts-wordpress-multisite-with-xampp-on-windows-7/

https://community.apachefriends.org/f/viewtopic.php?p=198815&sid=7a72729a95ed298148f8635dd414295a

how to create subdomains in apache(xampp) server?

Can someone please help me how to get subdomain to work on a PORTABLE version or how I should be doing it, or is editing windows hosts file compulsory?

Community
  • 1
  • 1
adam gouldie
  • 251
  • 3
  • 16

2 Answers2

0

not tested but try this:

NameVirtualHost *:80

<VirtualHost *:80>
    ServerAdmin admin@localhost.com
    ServerName localhost
    ServerAlias localhost
    DocumentRoot /xampp/htdocs/public
    <Directory "/xampp/htdocs/public">
        Options Indexes FollowSymLinks Includes ExecCGI
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin admin@localhost.com
    ServerName forums
    ServerAlias forums
    DocumentRoot /xampp/htdocs/public/forums
    <Directory "/xampp/htdocs/public/forums">
        Options Indexes FollowSymLinks Includes ExecCGI
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

Don't forget to write

127.0.0.1 forums

to your hosts file, if you don't have a DNS-Server.

Florian D
  • 56
  • 1
  • 9
  • Ok I done the above and edited hosts file, instead of the homepage loading, it redirects to the forums folder and a 500 internal error "forums.localhost/forums" should the folder name be invisible? – adam gouldie Apr 17 '15 at 13:53
  • Yes try it with "forums.localhost" without the subfolder. Because the DocumentRoot already links to the forums folder. The 500 internal error says that the virtual host already works, probably you have an error in your php-script or something like that. – Florian D Apr 17 '15 at 13:59
  • ok just checked and laravel has no impact on virtual host folder. But it is still redirecting. I added a htaccess file and it worked. Without it, it redirects to forums.localhost/forums and doesnt load the index.html – adam gouldie Apr 17 '15 at 15:34
0

You need to add forums.localhost to your hosts file.

Edit %SystemRoot%\System32\drivers\etc\hosts and add 127.0.0.1 forums.localhost.

I don't think there is another way to do this, sorry (maybe creating a script that automatically edits the hosts file, but it's quite dirty).

FrancoisBaveye
  • 1,902
  • 1
  • 18
  • 25
  • Ok I done the above and edited hosts file, instead of the homepage loading, it redirects to the forums folder and a 500 internal error "forums.localhost/forums" should the folder name be invisible? – adam gouldie Apr 17 '15 at 13:53
  • Do you have a .htaccess file or a code that rewrites the URL (and adds "forums" at the end of the URL) ? – FrancoisBaveye Apr 17 '15 at 13:55
  • I got a feeling I know what it might be. Im using a laravel folder in public. I thought I might be able to install a new subdomain there. But it doesn't work like that for laravel – adam gouldie Apr 17 '15 at 14:18