473,568 Members | 2,784 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

header redirection and adress bar

Hi,

I have a problem with redirection using the header function. The page
towards which I redirect loads correctly, but the url in the browser's
address bar is different is that of the redirecting page. Both pages are
located in different directories, so that my relative links don't work in
the page, because the browser retrieves the current directory from the wrong
url in the location bar.
This problem occurs only on the server of my webhosting provider, not on my
local machine where I can see the correct url after redirection. So I
assume, this is a server specific setting. But how can I change ist?

TIA,
Bernd
Jul 17 '05 #1
7 4855
"Bernd Liebermann" <12**@bernd-liebermann.de> wrote in message news:<c1******* ***@online.de>. ..
Hi,

I have a problem with redirection using the header function. The page
towards which I redirect loads correctly, but the url in the browser's
address bar is different is that of the redirecting page. Both pages are
located in different directories, so that my relative links don't work in
the page, because the browser retrieves the current directory from the wrong
url in the location bar.
This problem occurs only on the server of my webhosting provider, not on my
local machine where I can see the correct url after redirection. So I
assume, this is a server specific setting. But how can I change ist?


How are you redirecting the page? Can you post a code sample to look at?

/s/ WP
Jul 17 '05 #2
>
How are you redirecting the page? Can you post a code sample to look at?

/s/ WP


Sure.

if ($some_conditio n) {
header("locatio n:/update/update1.php");
exit;
}

No characters sent to the page at that point.

As I said, update1.php is processed correctly, only that the url of the
redirecting page located in "/" stays in the address bar. So any relative
links in update1.php use "/" as basedir instead of "/update". I know that
there are workaraounds like clientside redirection or specifying <BASE>
information in the html header. But I would like to understand why this
causes problems on my whp's server and not my local pc.

Thanks for your interest.
Bernd
Jul 17 '05 #3
Bernd Liebermann wrote:
header("locatio n:/update/update1.php");
That would be the proper way to engineer a redirect in PHP, save that
the Location field value does not consist of an absolute URI: an all-
too-common violation of RFC2616.
No characters sent to the page at that point.
Right. The redirect wouldn't happen otherwise.
As I said, update1.php is processed correctly, only that the url of the
redirecting page located in "/" stays in the address bar. So any relative
links in update1.php use "/" as basedir instead of "/update".
(ITYM "/update/", if I've interpreted "basedir" as what you'd
intended it to mean. It'd be better to express this "basedir" in
terms of an "absolute 'base URL'", using a dummy domain if you like.)

Any browser behaving like that is severely broken. There are three
ways to determine the base URL of an HTML document (HTML4.01, sec.
12.4.1); fetching the contents of the address bar is definitely *not*
one of them. What browser misbehaves this way?
I know that there are workaraounds like clientside redirection
You misspelt "nasty hacks". :-)
or specifying <BASE> information in the html header.
Using the BASE element is certainly a possibility, but it ought to be
unnecessary for any user-agent worth its salt. I'd rather get to the
root of the problem, and so would you:
But I would like to understand why this causes problems on my whp's server
and not my local pc.


Will you provide a URL of a document demonstrating this?

--
Jock
Jul 17 '05 #4
Will you provide a URL of a document demonstrating this?


http://ro.bernd-liebermann.de/login.php
http://ro.bernd-liebermann.de/login.php.txt (for php-source)

http-user: debug
http-pwd: debug

On login.php, enter "1" for user and "dick" as password. This script calls
itsself and redirects to /update/update1.php if login succesful. The problem
occurs with IE and Netscape.

Thanks for your help!
Bernd
Jul 17 '05 #5
Bernd Liebermann wrote:
http://ro.bernd-liebermann.de/login.php
http://ro.bernd-liebermann.de/login.php.txt (for php-source)

http-user: debug
http-pwd: debug

On login.php, enter "1" for user and "dick" as password. This script calls
itsself and redirects to /update/update1.php if login succesful. The problem
occurs with IE and Netscape.


Well, sorry, I've no idea. My browser doesn't even get redirected.
I'd suggest removing the unnecessary gunk until you figure out what
the problem is.

--
Jock
Jul 17 '05 #6
"Bernd Liebermann" <12**@bernd-liebermann.de> wrote in message news:<c1******* ***@online.de>. ..
Hi,

I have a problem with redirection using the header function. The page
towards which I redirect loads correctly, but the url in the browser's
address bar is different is that of the redirecting page. Both pages are
located in different directories, so that my relative links don't work in
the page, because the browser retrieves the current directory from the wrong
url in the location bar.
This problem occurs only on the server of my webhosting provider, not on my
local machine where I can see the correct url after redirection. So I
assume, this is a server specific setting. But how can I change ist?


/**----------------------------------------------------------------------------------
* Redirect2URL()-Redirects to the given URL
*
* @param $url - can be absolute/relative url eg.
http://foo.com/foo.htm or just foo.htm
* @return - void
**/
function Redirect2URL($u rl)
{
$url = trim($url);
//note: === (three equal signs)...otherw ise it won't work
if ( ! preg_match("/^http:\/\/|https:\/\/|ftp:\/\//i", $url) ) //if
http:// is not found, then the url is relative...
$url = 'http://' . $_SERVER['HTTP_HOST'] .
(strpos($url, '/') === 0? $url :
(dirname($_SERV ER['PHP_SELF']).'/'.$url));
header('Locatio n: ' . $url); //use absolute URI
exit; // Make sure that code below does not get executed when we
redirect.
}/*---------Redirect2URL()-----------------------*/

This may work.

--
"Success is not what you achieve, but it is what you die for"
If you live in USA, please support John Edwards.
Email: rrjanbiah-at-Y!com
Jul 17 '05 #7
Thanks, this works perfect!

Bernd

"R. Rajesh Jeba Anbiah" <ng**********@r ediffmail.com> schrieb im Newsbeitrag
news:ab******** *************** ***@posting.goo gle.com...
"Bernd Liebermann" <12**@bernd-liebermann.de> wrote in message news:<c1******* ***@online.de>. ..
Hi,

I have a problem with redirection using the header function. The page
towards which I redirect loads correctly, but the url in the browser's
address bar is different is that of the redirecting page. Both pages are
located in different directories, so that my relative links don't work in the page, because the browser retrieves the current directory from the wrong url in the location bar.
This problem occurs only on the server of my webhosting provider, not on my local machine where I can see the correct url after redirection. So I
assume, this is a server specific setting. But how can I change ist?


/**-------------------------------------------------------------------------
--------- * Redirect2URL()-Redirects to the given URL
*
* @param $url - can be absolute/relative url eg.
http://foo.com/foo.htm or just foo.htm
* @return - void
**/
function Redirect2URL($u rl)
{
$url = trim($url);
//note: === (three equal signs)...otherw ise it won't work
if ( ! preg_match("/^http:\/\/|https:\/\/|ftp:\/\//i", $url) ) //if
http:// is not found, then the url is relative...
$url = 'http://' . $_SERVER['HTTP_HOST'] .
(strpos($url, '/') === 0? $url :
(dirname($_SERV ER['PHP_SELF']).'/'.$url));
header('Locatio n: ' . $url); //use absolute URI
exit; // Make sure that code below does not get executed when we
redirect.
}/*---------Redirect2URL()-----------------------*/

This may work.

--
"Success is not what you achieve, but it is what you die for"
If you live in USA, please support John Edwards.
Email: rrjanbiah-at-Y!com

Jul 17 '05 #8

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

Similar topics

1
6262
by: Nick Whitelegg | last post by:
Hello, I'm having an odd problem with combining an authentication session variable with header() redirection. Basically I have an authentication script which checks a username/password. If the login is correct a session variable containing the username is set and the user is redirected to the (restricted access) main menu page. The...
0
2588
by: Phil Powell | last post by:
Based upon the following articles: http://www.experts-exchange.com/Web/Web_Languages/PHP/Q_20708448.html http://www.experts-exchange.com/Web/Web_Languages/PHP/Q_20717295.html...
1
1818
by: Webstyler | last post by:
Hi, I must create a redirect : 1@mysite.com must open www.mysite.com and The url must remain 1 @mysite.com I have obtain redirect correctly with this code : <script language="Javascript"> <!-- var indirizzo = window.location;
5
3693
by: Ian | last post by:
Can anyone help with a problem I am having regarding redirection. I'm using the following php call to redirect users to a site and automatically enter the required login name and pass for the target site: header("Location: $link"); exit(); where $link is something like:
13
6544
by: Raj | last post by:
Is there any way to delete a particular node from a singly linked list where the header of the list is unknown.Only pointer available is the one which points to the node to be deleted
3
1918
by: maya | last post by:
yes I know, this has been asked many times, but I don't quite the answers: usu. answers are to put the redirect code -- in my case $URL = "out.php?msg=selected+records+have+been+deleted+from+the+database."; header("Location: $URL"); BEFORE any HTML output (does this include 'echo' output's?) but: if, like in my case, for example, I...
1
1644
by: chandra.somesh | last post by:
I generally use Response.Redirect(url,false) for redirections. Is there a size constarint on the HTTP Response Location Header ? Also Is the behavior defined if we exceed this limit? In my web app there are cases where the url being passed to the redirection method is very long.What should be the expected behavior in such cases? In my...
0
1261
by: comp.lang.php | last post by:
<? header('Pragma: no-cache'); // ENSURE CLIENT-SIDE CACHE FLUSHING $url = "$projectURLPath/index.php"; if ($_REQUEST) $url .= '?logoutMsg='. urlencode($_REQUEST); if ($willAuthenticate && $willUseSSL) { $dest = 'https://' . $_SERVER . $url; } elseif ($willBasicAuthenticate && $willUseSSL) { $dest =...
5
6093
by: One | last post by:
Hi guys - I have a problem after a client clicks a Confirm button on a form - the form processes the data, inserts into a database, and then redirects using header Location. I have tested this on two different Linux/Apache servers. One works perfectly, the other takes about 90 seconds to redirect. Has anyone seen this issue before ? It...
0
7604
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7916
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8117
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7962
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6275
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5498
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5217
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2101
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
932
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.