Second slash on production server

Posted by Morecoffee, 03-07-2010, 01:52 PM
Hello, When I develop PHP scripts on my local server and use a redirect they work fine. When I upload them to the production (a reseller environment) server I end up with 2 slashes rather than one like it should be. I would like to change my test environment so it works the same as the production server. My redirect line... header ("Location: cantposturl://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/login.php"); If I leave the slash in (/login.php) when the script is uploaded to the production server it will create the double slash. If I take out the slash in my test environment it will not work. Not a big deal but it would be nice if I could upload and download a script and not have to modify it for each location. I am thinking I might need to modify the apache conf file on my test server, which is xampp on a windows box. Thanks

Posted by Dark Light, 03-07-2010, 02:09 PM
Can you post the PHP Variables part of an phpinfo() output for both servers? Are the two servers different operating systems? Also, are your PHP versions different (mainly, is the local server's version before PHP 4.3)? Checkout http://uk3.php.net/dirname for information on why dirname() returns slashes in different environments. Hope that helps!

Posted by Morecoffee, 03-07-2010, 02:25 PM
Production server is linux PHP Version 5.2.1 Development is Windows (xampp) PHP Version 5.2.5 I will look at the link you supplied as well. Thanks Last edited by Morecoffee; 03-07-2010 at 02:33 PM.

Posted by Steve_Arm, 03-07-2010, 02:42 PM
You can always do that: str_replace('//', '/', dirname($_SERVER['PHP_SELF']))

Posted by Morecoffee, 03-07-2010, 02:57 PM
Yes I saw the replace solution. I was hoping that there would be something I could change on the development server that would work for everything. I have quite a few files to change if I can't find a global solution.

Posted by Dark Light, 03-07-2010, 03:01 PM
Check the comments on the PHP website page I linked to, and read the comment by "joe dot naylor at gmail dot com" You could then go and do a find and replace on all your files, converting dirname to safedirname. Or you could use Steve's suggestion, though you might want to encapsulate that into a function. Hope that helps,

Posted by energizedit, 03-07-2010, 03:09 PM
It seems as if there is a php setting that is different between the 2 environments.

Posted by covehosting, 03-07-2010, 04:25 PM
yeah .. there is a Different between the 2

Posted by Morecoffee, 03-07-2010, 04:34 PM
The difference... would it be a setting in the php.ini file?

Was this answer helpful?

 Print this Article

Also Read

merchant account

Posted by cass, 09-03-2002, 06:33 AMHi, Just hoping someone could advise on why hostcharge seems...

Php as CGI or not.

Posted by Vinayak_Sharma, 01-13-2008, 08:37 AMOk I am configuring a fresh/new WHM/cPanel server...

Sprynex ?

Posted by zshelton, 09-04-2002, 12:27 AMDoes anyone here have any experience with Sprynex? good...

Setting up new Network, Security concern on DDOS

Posted by EricTham, 04-15-2009, 11:15 PMI am intending to setup a network as the following:...

Help me in this!

Posted by rathin, 03-28-2008, 02:19 PMHelp needed in redirection of certain browser,I haveing...