It was up to this task since yesterday. I haven’t done this before, setting sub domain- virtual host on local system. I tried a lot yesterday but in vain, however when I came to office today I configured it successfully.
As I was stuck in the middle and feel lot of pain, so I better write it for those facing the same issue.
Why I was up to this task?
Well, actually my client was facing problem and reported that session is not working properly on domain and sub domain. So I was having no way other than setting virtual host.
However before leaving yesterday, I talked to my client that I am unable to solve this problem. He told me that I shouldn’t be worried about it because he will take care of this issue. The more important thing is that when I arrived today, I found that the problem has already been solved. Thanks to him for giving my favor.
Thought the problem has been solved, but still is worthy to write a small post here because I have successfully solved the problem.
Before going to discuss it, I would like to tell you that the configuration has been taken place on window so the paths may not be same.
Let have a look.
First of all you will need to open.
I assumed that you have install xampp.
And add following lines to httpd-vhosts.conf file.
Options Indexes FollowSymLinks
Allow from all
Here I have defined server localhost pointing to my default htdocs directory and another host mysite.com.localhost pointing to “C:/xampp/htdocs/mysite/”.
Another important thing is <VirtualHost *:80>
Here you would need to specify the port. In my case its 80.
If you don’t specify the port on which apache listen, apache may take you to the same page for both the server. So be careful.
Next go to your Window/system32/dirvers/etc/ and open hosts file.
You will find
At the end of the file. Add following line next to it.
Reboot your system and you are done.