Hi, I'm a relative newb with wamp server and web development. I've been asked to take over the development of a website.

when I'm accessing the site locally everything works fine. But when I upload the site to our online server and I try to access it remotely from another machine/through the url.. whenever I click on a link the site tries to redirect to the "localhost/...." and then says it can't connect to the webpage because the machine I'm currently on is looking into it's local directories for the page (localhost) as opposed to looking for them on the server's directories..

does anyone have any ideas why this is happening?

Hey Marty6,

This will more than likely just be because of how you have coded the links, I imagine they look like this:

<a href="http://localhost/">Link</a>

All you have to do is replace localhost with the actual domain name of the website (in the source code files) and things should be fine.

actually the links that the person before me put into the code look something like..

<?php
        echo '<a  href="'.$_SERVER['PHP_SELF'].'?registration_tag=1">Sign up</a>';
?>

and when I look at the source directly from the website through my browser it comes up as:

<a  href="/index.php?registration_tag=1">Sign up</a>

Have you got a link to the website in question by the way?

unfortunately the site is not officially launched yet so I'm not allowed to circulate the url just yet. :(

I believe the reason why they want to echo the url dynamically/code generated, is that this is going to be in a side bar that might be located on multiple pages, not just on the index.php, so they want it to link to the specific page you're currently on not just to the index.

but for now I'll hard code the links just so we get something working in the meantime (we haven't added the other pages that need the sidebar yet).

If they just want to attach the query string to the current file in the links they don't need to use PHP_SELF but can just specify the query string like this:

<?php
        echo '<a href="?registration_tag=1">Sign up</a>';
?>

sweet, I'll do that instead..

also I just found the problem, apparently the person who was coding the site before me decided to hardcode a global variable with localhost and then buried it in a side file that was accessed by another side file and that value would override pretty much everything.. and that was the reason why everything was being redirected to localhost no matter what I did. And he never told anyone about this, or that it would be needed to be changed to the host name when the site goes live.

thanks for your help :) I'll definitely use the shorter link you suggested.

If you can then try to use full links if you can, if I'm correct it is better for SEO.

But the way I have showed you will be more than sufficient for providing the functionality to the end-user :)

Glad it is all working for you now anyway.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.