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 [email protected]
    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 [email protected]
    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?

2 Answers 2

0

not tested but try this:

NameVirtualHost *:80

<VirtualHost *:80>
    ServerAdmin [email protected]
    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 [email protected]
    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.

Sign up to request clarification or add additional context in comments.

3 Comments

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?
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.
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
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).

3 Comments

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?
Do you have a .htaccess file or a code that rewrites the URL (and adds "forums" at the end of the URL) ?
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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.