My question may be stupid, But honestly I searched a lot and got success but not complete.
I use xampp with windows 8.
In the example, a virtual host of the same name is configured on a machine at 192.168.111.2. The ProxyPreserveHost On directive is used so that the desired hostname is passed through, in case we are proxying multiple hostnames to a single machine.
My host file looks as follows.
My httpd-vhosts.config looks as follows.
This works perfect for http.But I have enabled ssl.
When I type
http://localhost
or https://localhost
, Both work fine.When I type
http://mysite.com
it works, when I type
https://mysite.com
it is redirected as https://mysite.com/xampp/
and shows me default welcome page of xampp.I tried following things.
1) instead of using 127.0.0.1, I tried using *:80 in httpd-vhosts.conf But result was same.
2) instead of using 127.0.0.1, I tried using *:443 in httpd-vhosts.conf But at the time of restarting apache fails to start again.
Please let me know how can I access my site through domain name instead of localhost with https or http.
swapnesh18.6k22 gold badges76 silver badges112 bronze badges
Jeet ChaudhariJeet Chaudhari4531 gold badge4 silver badges14 bronze badges
6 Answers
I tried many things, But I think I missed basic edit.
Now all working fine.
Now host file is still the same as mentioned in question. I did not make any changes to it.
I changed port in httpd-vhosts.config as shows below.
Also the step I missed, was editing httpd-ssl.config file in same folder that of httpd-vhosts.config.
I just added following lines before last line of http-ssl.config file i.e. < /IfModule>
Thank You all friends for helping me lot on this, Without your links I would never ever be able to find out that I need to edit one more file.
Jeet ChaudhariJeet Chaudhari4531 gold badge4 silver badges14 bronze badges
Let me explain step by step for other guys too.
1. Map your custom domain name to localhost in HOSTS file.
Open hosts file and add below line.
2. Tell XAMPP about your custom domain.
Add below content to httpd-vhosts.conf
If you have port for your localhost, then add it as
<VirtualHost *:80>
Restart apache,Now you can access http://example.com in your browser.
3. If you want to access https://example.com
Add below line to httpd-vhosts.conf
Anurag PrashantAnurag Prashant
I started with multiple custom domains. See new code below:
Note: WordPress strips backslashes, so below I’ve replaced them with forward slashes. I believe it with work regardless either way.
Xman ClassicalXman Classical3,3551 gold badge21 silver badges21 bronze badges
I'm not too familiar with apache but perhaps not specifying a port defaults to :80 and adding this would magically fix everything?
InsensusInsensus
I have been googling for hours trying to figure out why the newest XAMPP release puts 1200MS on page generation times... I thought it was maybe my code working with some pretty complex class systems yet.. this thread pointed out the whole localhost <> 127.0.0.1
I'm on Windows 7 and I didn't think to use CMD to 'ping localhost'
the result was '::1:' not 127.0.0.1
After a quick windows/system32/drivers/etc/host file edit to uncomment out the line
127.0.0.0 localhost
My page times went back to normal. Might be someone else is having this problem recently and seeing as this thread ranks top in Google then good luck!
FaTeFaTe
I use my own domains (ended with .lc) for development web application on localhost. I will describe simple solution for dynamic .lc domains and development enviroment that works without dependency on internet connection.
I wrote about it on my blog too: http://www.michalseidler.com/development/localhost-development-enviromet-for-php/
For this example i try describe configuration of local dynamic domains *.lc with Wamp Server. I have my projects stored in C:wampwwwprojectsprojectname and i use dynamic maping projectname.lc. This means that i can access every project directory with domain [project direktory name].lc
Step 1 – configuration of local WAMP server
First of all you need place configuration of *.lc domain into httpd.conf:
You need insert .htaccess file into projects direktory (in my example into: C:wampwwwprojects) this configuration maps *.ls domains to project direktories. Ex.: If you have sources in direktory ‚myapp‘ you can use www.myapp.lc to open it in browser.
After this changes restart Wamp Server
Step 2 – configuration of local DNS server
Because we can’t use *.lc in Windows host file we need instal local DNS server. I choose Acrylic DNS Server because it is very simple for configuration.
After instalation find AcrylicHosts file (C:Program Files (x86)Acrylic DNS Proxy) and insert new line:
This is only DNS configuration we need so restart Acrylic DNS service.
Step 3 – configuration of network adapter
Final step is install new fake network adapter and assign DNS server:1.Click the Start menu.2.Search for “cmd“.3.Right-click on “cmd” and select “Run as Administrator”4.Enter “hdwwiz.exe”5.In the „Welcome to the Add Hardware Wizard“, click Next.6.Select „Install the hardware that I manually select from a list (Advanced)“ and click Next.7.Scroll down and select „Network adapters“ and click Next.8.Select under Manufacturer „Microsoft“ and then under Network Adapter „Microsoft Loopback Adapter“ and click Next.
In next step you must change TCP/IP settings of new created adapter:1.Log on to the computer by using the Administrator account.2.Click Start, point to Control Panel, and click Network Connections.3.Right-click the Loopback connection and then click Properties.4.In the This connection uses the following items box, click Internet Protocol (TCP/IP), and then click Properties. The Internet Protocol (TCP/IP) Properties dialog box appears.
Now close all dialogs and its done! You can try open [your project name].lc
Michal SeidlerMichal Seidler
Not the answer you're looking for? Browse other questions tagged phpapachexampplocalhostdomain-name or ask your own question.
Hi I have been trying for hours with many tutorials and I still not able to get the virtual host running on windows8 platform. I am using xampp 1.8.3. My xampp folder is installed as xampp2 in the c-directory
Step 1: I edited the System32driversetchosts file as such
127.0.0.1 xampp.local
127.0.0.1 localhost
Step 2: I enabled the following lines in httpd.config:
Step 3: I edited apacheconfextrahttpd-vhosts.conf
Step 4: restarted xampp and tried localhost and it worked. But when I tried www.xampp.local chrome complains
Oops! Google Chrome could not find www.xampp.local
I really don't know what else to do.
madi
madimadi4,7773 gold badges27 silver badges47 bronze badges
4 Answers
Use the following code... and edit accordingly in your http-vhosts.conf
And use this in your windows host file without the pound # sign infront
The directory can be linked from any directory, not specifically from the htdocs folder and the server name can end in .anyname, but be becareful when using .coms and .nets, It may cause confusions while trying to access them.
But in case you still like to use .com or .net, which i usually do. This is how to get around with it, to access a .com you created for yourself (local) in your vitual host, this is how you do it from the address bar
And for your external .com
blakrokublakroku
Have you tried using forward slashes instead of backslashes?
Vaibhav SagarVaibhav Sagar
Oh, It was really for painful for me to get it work in Apache 2.4.9.I found a lot of tutorials, but I can not make it work.
MY SOLUTION IS FOR APACHE 2.4 AND ABOVE VERSION.I have tested it with Apache 2.4.9
You need to edit two files.PLEASE MAKE BACKUP OF THIS TWO FILE BEFORE YOU MAKE CHANGES.If you write anything wrong , your localhost will not work even you uninstall xampp and then again install xampp.
STEP 1:
Edit this file
C:WindowsSystem32driversetchosts
Open this file using 'Run As Adminstrator' from Notepad(Very Important).You can do this by
Start Menu > Notepad >Right Click > Run As Adminstrator > Open file
add these two lines at the end of this file
Either you go testsite.dev or www.testsite.dev , it will now try to access from your local machine NOT from the web
STEP 2:
E:xamppapacheconfextrahttpd-vhosts.conf
You can edit this file normally , there is no need to run this file as 'Run As Adminstrator'Add the follwing lines at the end of this file
I setmy xampp in E drive , so when you copy from here , make sure you change it according to your xampp installation.the Last part is little interesting.I am pointing out this potion
Where can you find this code?In internet , you can find it in many places but might not work for you as that code will differentiate from your Apache version.SO WHAT'S THE SOLUTION?
At the end of file , you will see there are some commented lines already to show you a demo how to setup virtual host, just copy those lines and make necessary changes and it will work for you.I have attached a screenshot for better understanding
Rocker MarufRocker Maruf
Oops! Google Chrome could not find www.xampp.local
The above error is related to name resolution. Chrome cannot find where the site 'www.xampp.local' is. To resolve this, you have to add the fully qualified domain name to your hosts file:
chue xchue x17k6 gold badges46 silver badges65 bronze badges