Direct url to the local domain

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Direct url to the local domain

Postby iman007 » 12. October 2015 09:16

I am new with XAMPP. I store web sites folders in htdocs folder. I access to the local web site using url
Code: Select all
http://localhost/mywebsitefolder/index.php

Is there some way to access to the local web site using url:
Code: Select all
http://mywebsitefolder/index.php
:?:
Main issue with url
Code: Select all
http://mywebsitefolder/index.php
is that if I create a link with address
Code: Select all
<a href="/">sometext</a>
it links to the
Code: Select all
http://localhost/index.php
, which doesn't work(as my website url is
Code: Select all
http://localhost/mywebsitefolder/index.php
)
Link
Code: Select all
<a href="/">sometext</a>
works well on remote web servers (hosting).
Last edited by iman007 on 12. October 2015 10:04, edited 1 time in total.
iman007
 
Posts: 2
Joined: 12. October 2015 09:02
Operating System: Windows

Re: Direct url to the local domain

Postby Nobbie » 12. October 2015 09:57

Sorry, but could you explain this better?? I really do not understand, what you mean. Please do not use "...." (this is hard to understand) and please provide full URLs like http://localhost/mywebfolder/index.php
Nobbie
 
Posts: 13183
Joined: 09. March 2008 13:04

Re: Direct url to the local domain

Postby iman007 » 12. October 2015 10:07

I am new on the forum and can't create links, only code.
All I want is to access to my local domain using
Code: Select all
 http://mywebsitefolder/index.php
url, not
Code: Select all
http://localhost/mywebsitefolder/index.php
iman007
 
Posts: 2
Joined: 12. October 2015 09:02
Operating System: Windows

Re: Direct url to the local domain

Postby Nobbie » 12. October 2015 10:22

There are different solutions for your problem. The quick & easy (but dirty) solution:

simply edit DocumentRoot in httpd.conf and change it from c:/xampp/htdocs to c:/xampp/htdocs/mywebfolder. Also adapt the following <Directory....> option to c:/xampp/htdocs/mywebfolder
If you do so, your project will appear under http://localhost/index.php (instead of http://localhost/mywebfolder/index.php), thats exactly what you need. Disadvantage: the Xampp Dashboard does not appear anymore.

The "clean" solution: define VirtualHosts for your Xampp Installation. You need two VirtualHosts, one is "localhost" (you need it only for the existing dashboard and/or phpmyadmin installation), the other is (for example) "mywebfolder" (but i dont like this name, because it sounds like "folder", but it is a servername instead). You should take another name, lets say "mywebserver". In the VirtualHost for "mywebserver" (see the Apache Documentation about VirtualHosts) define DocumentRoot as shown above c:/xampp/htdocs/mywebfolder. When the VirtualHosts are ready (and ok), you may reach your project via http://mywebserver/index.php

For the VirtualHost "mywebserver" you have to edit the Windows hosts file (see Wiki if you are unsure) and insert one line for this name:

127.0.0.1 mywebserver

If you dont do so, you will receive an error "unknown server" when you enter http://mywebserver in your browser.
Nobbie
 
Posts: 13183
Joined: 09. March 2008 13:04


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 126 guests