localhost remval

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
abhims2
Forum Newbie
Posts: 2
Joined: Mon Apr 12, 2010 11:46 pm

localhost remval

Post by abhims2 »

Hi,

I am using XAMPP server to run my PHP code. The link I get to run my website is anything placed in "htdocs" folder along with http://localhost/.....

I would like to remove localhost from my website link. How can I do that?
Mu link looks like this "http://localhost/college_menu/admin/index.html". College_menu is folder inside htdocs folder and admin is sub folder inside college_menu. Please let me know how can I remove localhost frm the link....

Many thanks in advance!!!

Abhilesh
User avatar
omniuni
Forum Regular
Posts: 738
Joined: Tue Jul 15, 2008 10:50 pm
Location: Carolina, USA

Re: localhost remval

Post by omniuni »

You could probably use a relative link.

Other than that, localhost is just the server. As long as your links are relative, then when you upload the website to your host, the links will still work.
abhims2
Forum Newbie
Posts: 2
Joined: Mon Apr 12, 2010 11:46 pm

Re: localhost remval

Post by abhims2 »

Thanks a lot...

but I dont know how to make links relative. can you please give me some info on how to do that?

Many thanks!!

abhilesh
User avatar
omniuni
Forum Regular
Posts: 738
Joined: Tue Jul 15, 2008 10:50 pm
Location: Carolina, USA

Re: localhost remval

Post by omniuni »

Relative links are just like moving around in a terminal.

Let's say you have:

-+public_html
|
|- index.php
|- login.php
|-+college_menu
| |
| |- index.php
| |-+admin
| | |
| | |- index.html
| |
| |- college_menu.gif
|
|- header_image.png
|- logout.php

now, let's say I want to get from index.php in college_menu to the admin folder's index.php. Because index.php is the default when entering that folder, I use the link "admin". so <a href="admin">Admin</a>

Let's say I want to exit that folder. I can go up a level using the link <a href="../">Return to Website</a>.

I can return to my localhost index, as well <a href="../../">Return to Localhost</a>

If you later upload college_menu, then your admin link will still work. Only "return to localhost" won't because it is no longer on localhost, a location (up-two-levels) that does not exist in your production environment.
Post Reply