Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My website is on a shared server. Having DNS issues, this seems to be the only way. I need to get the real and absolute path to my website like without asking the support is this possible? With the IP address and path.

share|improve this question
That IP address you've provided looks like a home machine. The answers on this question are generic because you do not specify the server software. What details do you already have (a domain name?) If your shared host frequently changes IP addresses, you should consider moving to a more reliable host. – Lekensteyn Dec 23 '11 at 11:23
Its apache. The IP address above is just a sample. – Mob Dec 23 '11 at 14:01
Operating System? If possible, mention the hoster name. – Lekensteyn Dec 23 '11 at 14:02
Can you clarify a bit more. WHat are you trying to achieve. If you are looking for hostname to ip traslation for the url, then nslookup in windows would tell you the name it could find for the ip. The ~ specifies the userdir. See the httpd.conf or one of included .conf for userdir directive is included. – Naai Sekar Dec 25 '11 at 14:56
This depends on how the actual server is configured. It sounds like you want to access your site via IP. If your using a hosting company the is very unlikely. Unless you have a dedicated IP, there is probably only a 404 or a redirect site waiting. What's the actual problem your trying to fix? if it's code, then it may be a 'relative' problem, maybe hard coded variables that don't work as expected. Or your 'environment' hasn't been made 100% clear to you. Add a comment and let us help. – Mister IT Guru Dec 29 '11 at 20:40

Define "absolute path". Absolute file path on the webserver? Likely /home/mywebscom/public_html.

If you meant URL, there is no definite URL for all servers, but if userdirs are enabled, you can access the website using To retrieve the IP address, you should look in the documentation of your webhost. The IP is unlikely to change, but in the event of an IP change of the server your website is put on, you can get the IP by running:

share|improve this answer

For the time being you can add an entry to your hosts file but you should really be working on the DNS. I don't understand how you think the path to your website is related to your DNS not resolving or how knowing it is going to help.

share|improve this answer
I assume he means that he can't access it by going to the IP, which makes perfect sense if it's a Virtual Host redirecting based on URL. If he gets the absolute path he can just browse to it using that. – Dan Dec 23 '11 at 10:16
I don't own the server. I'm a client of a webhosting agency. I have no rights to the host files. – Mob Dec 23 '11 at 10:27
Your local hosts file. Add an entry for with your IP and it will work the same as if DNS was working correctly. But only on that machine. – Dan Dec 23 '11 at 10:59

If your server has PHP installed (usually all apachie servers now are php enabled) this simple PHP script will return the absolute path wherever you will place it:

echo getcwd(); // Short for `Get Current Working Directory` 

Just save this on a file curdir.php and run it via URL for example

There are also options to retrive the IP Address, Server Name etc... with $_SERVER variable

echo $_SERVER['SERVER_ADDR']; // The IP address of the server under which the current script is executing.
echo $_SERVER['SERVER_NAME']; //Gets the server name

You can see full listing of this variable and find almost everything about the server where your website is here:

share|improve this answer

Web servers use "Host" header of requests to detect virtualhosts. So probably there isn't any path like

You can add your ip address and domain to hosts file of your system and connect server using your domain. So web server will serve your virtualhost instead of default virtualhost.

You can add a newline to hosts file contains ip address and domain as space seperated.


share|improve this answer

Copy and paste this into a .php file (path.php or something) and upload it to your server. Call it in a browser; such as et voila, your absolute path:

$path = getcwd();
echo "This Is Your Absolute Path: ";
echo $path;
share|improve this answer
I don't think that he asked for this kind of "absolute path" – Lekensteyn Dec 23 '11 at 11:24

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.