By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,718 Members | 1,461 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,718 IT Pros & Developers. It's quick & easy.

where is // in redirect coming from??

P: n/a

I'm hoping someone out there has experienced this and can tell me right off
what is going on. I'm getting a double slash in my URL when I do a redirect
if my host is a 'web' host, but when my host is localhost (on my development
machine and not on the web) I get the desired single slash.

The redirect code is as follows:

header("Location: http://".$_SERVER['HTTP_HOST'].

Note that I tack on '/index.php' because in testing on my localhost I found
I needed the leading slash since dirname($_SERVER['PHP_SELF']) was not
returning a string ending in a slash (ie, no slash after the folder location
for the web project). So the leading slash HAS to be there for this code to
work on my localhost development machine. However, when uploaded to the
regular site, I find that the leading slash should not be there, as I wind
up redirecting to (for example):

Now, it happens that the double slash still works (it loads the page),
although it DOES effect how some of the code executes under a refresh
(selection of random backgrounds based on cookie settings when a page is
first reloaded - truly bizaar!).

Is there an easy way I can recode the redirect so it will work correctly on
both my localhost development machine and on the web?

Jul 17 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.