Backslash - Forwardslash Issue
Moderator: General Moderators
-
grasshopper
- Forum Newbie
- Posts: 7
- Joined: Thu Feb 03, 2005 9:55 am
Backslash - Forwardslash Issue
Recently I moved an intranet site from a Linux box to a Windows Server 2003. The setup is:
Apache 2.0.47
PHP 4.3.10
PostgreSQL 8.0
The main page (index.php) for the site comes up fine. I put in my user id and password and hit login. This should throw me to another page, but instead I get a pop-up error stating that "myserver.com\page_I_want.php could not be found. Please check the name and try again."
The page exists, and here is the kicker - this all works with IE 6, and will not work with Firefox 1.0.
I did notice that the error states mysite.com\page.php - the slash is in the wrong direction. Should be / and not \.
I figure it has something to do with the way Windows does paths. This site worked fine on the Linux box and none of the php code has changed.
Can someone shed some light on how to fix this. I've been over the php.ini and httpd.conf number of times and I can't see anything wrong. I know PHP itself works and loads all the mofules I want.
Please help!
Apache 2.0.47
PHP 4.3.10
PostgreSQL 8.0
The main page (index.php) for the site comes up fine. I put in my user id and password and hit login. This should throw me to another page, but instead I get a pop-up error stating that "myserver.com\page_I_want.php could not be found. Please check the name and try again."
The page exists, and here is the kicker - this all works with IE 6, and will not work with Firefox 1.0.
I did notice that the error states mysite.com\page.php - the slash is in the wrong direction. Should be / and not \.
I figure it has something to do with the way Windows does paths. This site worked fine on the Linux box and none of the php code has changed.
Can someone shed some light on how to fix this. I've been over the php.ini and httpd.conf number of times and I can't see anything wrong. I know PHP itself works and loads all the mofules I want.
Please help!
-
grasshopper
- Forum Newbie
- Posts: 7
- Joined: Thu Feb 03, 2005 9:55 am
I'm pretty sure it's not the code, but if you want to see it, here it is. The index.php is not the file that does the redirection. It only serves as a starting point, get's the user's id and password and passes that info via $_POST variables to a login.php which inturn does the redirection to a different page - the page that will not show. Here's a snippet of code that does the redirection:
Again, all of this stuff works if I'm using Internet Explorer, but stops to work if I use Firefox.
Code: Select all
if ($redirect != '') {
$relative_uri = ltrim($redirect, '/');
} else if ($_SESSIONї'_usertype'] == 'Client') {
$relative_uri = 'myissues.php';
} else if ($_SESSIONї'_usertype'] == 'Root') {
$relative_uri = 'domains.php';
} else {
$relative_uri = 'unassignedissues.php';
}
$dirname = dirname($_SERVERї'PHP_SELF']);
$https = 'http'.($_SERVERї'HTTPS'] ? 's' : '');
$headertext = "Location: $https://".$_SERVERї'HTTP_HOST'].$dirname.(strrpos($dirname,'/')==(strlen($dirname)-1)?'':'/').$relative_uri;-
grasshopper
- Forum Newbie
- Posts: 7
- Joined: Thu Feb 03, 2005 9:55 am
-
grasshopper
- Forum Newbie
- Posts: 7
- Joined: Thu Feb 03, 2005 9:55 am
I'm not entirely sure how to do this. What I have done is used your script and punched in the location of the login.php page in the "get" dialog box and it comes back with header and HTML info, but nothing about variables passed. I don't think I'm doing this right.feyd wrote:if you switch login.php to use $_REQUEST (for this debugging only) then passing in the username and password to use via the url (get request) the script will show you the headers the script is sending back to the browser. .. just in case some of the code is odd..
I'd guess that $dirname is funky.
-
grasshopper
- Forum Newbie
- Posts: 7
- Joined: Thu Feb 03, 2005 9:55 am
feyd you are right in assuming that
and then I made it print out on the screen the value of $dirname1 and it came back as \. Then I made sure that the $_SERVER['PHP_SELF'] evaluates properly and it did - returned "/login.php". I also tried this:
to see if it returns the correct string - should be "c:" but instead I got "c:\"
Seems that when dirname() evaluates the string "/login.php" it does the job half right - it evaluates the path (droping the filename), but then it inverts the slash! Any ideas what's wrong?
I used this little bit of code in my login.php to see what it sees:I'd guess that $dirname is funky.
Code: Select all
$dirname1 = dirname($_SERVERї'PHP_SELF']);Code: Select all
$dirname1 = dirname('c:/');Seems that when dirname() evaluates the string "/login.php" it does the job half right - it evaluates the path (droping the filename), but then it inverts the slash! Any ideas what's wrong?
-
grasshopper
- Forum Newbie
- Posts: 7
- Joined: Thu Feb 03, 2005 9:55 am
So how do I fix this. If I run dirname("/path") it returns "" instead of "/"feyd wrote:dirname() and it's related functions use file system functions, typically, to determine location information, as they are for the file system, not for web files. So it is functioning correctly.
I guess my php scripts depend on the value it returns for redirection purposes, and since a "" is returned, a redirection is formed as such:
myserver.com\somefile.php instead of myserver.com/somefile.php
Mozilla Firefox can't deal with that but IE can. Since I'm using Firefox all the time I'd like this to work.
Can anyone help?
-
thegreatone2176
- Forum Contributor
- Posts: 102
- Joined: Sun Jul 11, 2004 1:27 pm
-
grasshopper
- Forum Newbie
- Posts: 7
- Joined: Thu Feb 03, 2005 9:55 am
Thanks! I wasn't looking for a pretty solution, and this did the trick! Although I had to change the mixed search and mixed replace strings to the proper slashes i.e.thegreatone2176 wrote:a sort of lame way to fix it would be
$string = str_replace("/","",$string);
Code: Select all
$string = str_replace(""e;,"/",$otherstring);