473,406 Members | 2,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

where is // in redirect coming from??

Hi,

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'].
dirname($_SERVER['PHP_SELF']).'/index.php');
exit;

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):

http://www.lahdedah.net//index.php

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?

thanks,
-dg
Jul 17 '05 #1
0 1340

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Damo | last post by:
Could someone please help me. I am a newbie at PHP. I downloaded formail.php Version 5.0 from Jacks scripts( http://www.dtheatre.com/scripts/ )and changed the required areas to my email address and...
7
by: Donna Hawkins | last post by:
I want to use javascript to redirect to a URL which has been passed as a variable (in php). I have searched but cannot find any solution. I think this code is a basic redirect: <script...
2
by: Jason | last post by:
Hello, I have a class, transCore, that does certain work, and by default, prints its progress to the stand output. Later, I will to write a GUI class that encapsulate the transCore class. I...
11
by: Vic Spainhower | last post by:
Hello, I just purchased a new domain name and I've set it up as a redirect to a folder on my main site. What is happening is the index.php page checks a session variable to see if the user is...
1
by: Drebin | last post by:
I posted this over at the ASP.NET group, but you guys are pretty sharp - is this an obvious answer for anyone?? I'm really jammed up!! --------------------------------------- I am retrofitting...
15
by: Drebin | last post by:
I am retrofitting a central login application and want to be able to read the Request.ServerVariables so that when they have logged on, I can send them back to wherever they were trying to go.. ...
1
by: Henke | last post by:
Hi I have added a image button on a web page that is used for navigating back to the page I come from. I'm "jumping" between pages using Server.Transfer. Where can I find the address for the page I...
4
by: surfivor | last post by:
I have a simple problem in that I have developed various websites off of my domain such as: www.mydomain.com/my-friends-website I want to be able to have someone register a domain such as ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.