Last active
September 1, 2022 06:07
-
-
Save oozman/5530016 to your computer and use it in GitHub Desktop.
How to add a custom domain name on your localhost using XAMPP. Codes are based on Windows, but Step 2 onwards are pretty much applicable on other operating system.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Step 1: | |
Go to: C:\Windows\System32\Drivers\etc\hosts | |
And add this to the bottom of the file: | |
============= | |
127.0.0.1 your.domain.com | |
============= | |
Step 2: | |
Go to [your XAMPP directory]/apache/conf/httpd-xampp.conf | |
Step 3: | |
Go to the bottom of the file and copy & paste this code: | |
============= | |
<VirtualHost *:80> | |
DocumentRoot "[PATH TO YOUR CUSTOM FOLDER]" | |
ServerName your.domain.com | |
<Directory "[PATH TO YOUR CUSTOM FOLDER]"> | |
Options Indexes FollowSymLinks Includes ExecCGI | |
AllowOverride All | |
Require all granted | |
</Directory> | |
</VirtualHost> | |
============= | |
* Replace [PATH TO YOUR CUSTOM FOLDER] to the folder where your files are located. | |
Ex: C:/my/www/folder/ | |
* your.domain.com must be the same on Step 1 & Step 3 | |
Step 4: | |
Stop Apache on XAMPP, wait for 5 seconds, then click "Start" to start again your Apache. | |
If all things go well, you can go to your browser, type your.domain.com | |
and it will now happily point to your custom local folder. |
On mac, I get this message after following the instructions, any ideas?
Forbidden
You don't have permission to access / on this server.
Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.
Excellent. Great job man
Nice but I have a question. I'm trying to access this subdomain from a mobile device connected to the same wifi. So I type the IP address of my machine and I get redirected to the subdomain but I get "Could not connect to the server".
I'm running an SSL self signed, XAMPP, Windows 10. Do you have suggestion?
great effort.... short and easy to understand (Y)
It works. As easy as it seems. Thank you!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Дякую