1

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 99.23.154.23/~mywebscom without asking the support is this possible? With the IP address and path.

Mob
  • 11
  • 1
  • 1
  • 6
  • 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. – bagavadhar 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

5 Answers5

3

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:

<?php 
echo getcwd(); // Short for `Get Current Working Directory` 
?>

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

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

<?php
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: http://php.net/manual/en/reserved.variables.server.php

Spirit
  • 1,154
  • 8
  • 25
  • 45
2

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 http://ip.ad.dr.ess/~username. 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:

host the-server-on-which-your-site-is-hosted.example.com
Lekensteyn
  • 6,241
  • 6
  • 39
  • 55
2

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.

John Gardeniers
  • 27,458
  • 12
  • 55
  • 109
  • 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
  • 2
    Your local hosts file. Add an entry for mydomain.com 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
1

Web servers use "Host" header of requests to detect virtualhosts. So probably there isn't any path like http://ip.ad.dr.ss/~yoursite.

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.

e.g 1.1.1.1 mydomain.com www.mydomain.com

dirigeant
  • 221
  • 1
  • 4
0

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 http://www.yourdomainname.com/path.php et voila, your absolute path:

<?php
$path = getcwd();
echo "This Is Your Absolute Path: ";
echo $path;
?>
Moif Murphy
  • 254
  • 1
  • 3
  • 10