1

I use for my links in Zend:

<?php echo baseUrl('/some/path/to/an/action');?>

This behaves properly in Firefox. The application is portable without needing to use vhosts. For example: for this link

<a href="<?php echo $this->baseUrl('/admin/users'); ?>">Manage Users</a>

the expected URL should be http://myhost/webapp_folder/public/controller/action/params however this does not work in IE. I get http:///webapp_folder/public/controller/action/params. How can I fix this for IE? (when is microsoft going to realize that they made the most problematic browser off all time????)

$_SERVER array in FF

[REDIRECT_STATUS] => 200
[HTTP_HOST] => localhost
[HTTP_USER_AGENT] => Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12
[HTTP_ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
[HTTP_ACCEPT_LANGUAGE] => en-us,en;q=0.5
[HTTP_ACCEPT_ENCODING] => gzip,deflate
[HTTP_ACCEPT_CHARSET] => ISO-8859-1,utf-8;q=0.7,*;q=0.7
[HTTP_KEEP_ALIVE] => 115
[HTTP_CONNECTION] => keep-alive
[HTTP_REFERER] => http://localhost/industrial/public/admin/groups
[HTTP_COOKIE] => PHPSESSID=kiodpltbra87rkknebg56mcvf3
[HTTP_CACHE_CONTROL] => max-age=0
[PATH] => e:\eclipse\bin\;C:\Program Files (x86)\MiKTeX 2.8\miktex\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Common Files\Acronis\SnapAPI\;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files (x86)\GTK2-Runtime\bin;e:\wamp\bin\php\php5.3.0\;C:\Program Files (x86)\Rational\common;
[SystemRoot] => C:\Windows
[COMSPEC] => C:\Windows\system32\cmd.exe
[PATHEXT] => .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
[WINDIR] => C:\Windows
[SERVER_SIGNATURE] =>
[SERVER_SOFTWARE] => Apache/2.2.11 (Win32) PHP/5.3.0
[SERVER_NAME] => localhost
[SERVER_ADDR] => 127.0.0.1
[SERVER_PORT] => 80
[REMOTE_ADDR] => 127.0.0.1
[DOCUMENT_ROOT] => E:/wamp/www/
[SERVER_ADMIN] => admin@localhost
[SCRIPT_FILENAME] => E:/wamp/www/industrial/public/index.php
[REMOTE_PORT] => 50447
[REDIRECT_URL] => /industrial/public/admin/users
[GATEWAY_INTERFACE] => CGI/1.1
[SERVER_PROTOCOL] => HTTP/1.1
[REQUEST_METHOD] => GET
[QUERY_STRING] =>
[REQUEST_URI] => /industrial/public/admin/users
[SCRIPT_NAME] => /industrial/public/index.php
[PHP_SELF] => /industrial/public/index.php
[REQUEST_TIME] => 1289966668

$_SERVER array in IE

[REDIRECT_STATUS] => 200]
[HTTP_ACCEPT] => */*
[HTTP_ACCEPT_LANGUAGE] => en-US 
[HTTP_USER_AGENT] => Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; FunWebProducts; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2)
[HTTP_ACCEPT_ENCODING] => gzip, deflate 
[HTTP_HOST] => localhost
[HTTP_CONNECTION] => Keep-Alive
[HTTP_COOKIE] => PHPSESSID=9gdgck6s21umd2afj798aofnd0
[PATH] => e:\eclipse\bin\;C:\Program Files (x86)\MiKTeX 2.8\miktex\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Common Files\Acronis\SnapAPI\;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files (x86)\GTK2-Runtime\bin;e:\wamp\bin\php\php5.3.0\;C:\Program Files (x86)\Rational\common;
[SystemRoot] => C:\Windows
[COMSPEC] => C:\Windows\system32\cmd.exe
[PATHEXT] => .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
[WINDIR] => C:\Windows
[SERVER_SIGNATURE] =>
[SERVER_SOFTWARE] => Apache/2.2.11 (Win32) PHP/5.3.0
[SERVER_NAME] => localhost
[SERVER_ADDR] => 127.0.0.1
[SERVER_PORT] => 80
[REMOTE_ADDR] => 127.0.0.1
[DOCUMENT_ROOT] => E:/wamp/www/
[SERVER_ADMIN] => admin@localhost
[SCRIPT_FILENAME] => E:/wamp/www/industrial/public/index.php
[REMOTE_PORT] => 50504
[REDIRECT_URL] => /industrial/public/admin/users/
[GATEWAY_INTERFACE] => CGI/1.1
[SERVER_PROTOCOL] => HTTP/1.1
[REQUEST_METHOD] => GET
[QUERY_STRING] =>
[REQUEST_URI] => /industrial/public/admin/users/
[SCRIPT_NAME] => /industrial/public/index.php
[PHP_SELF] => /industrial/public/index.php
[REQUEST_TIME] => 1289966883 

Strangely all the resources(css, js, images) are loaded correctly. It's the links that are not having the right format.

Marc B
  • 356,200
  • 43
  • 426
  • 500
user253530
  • 2,583
  • 13
  • 44
  • 61
  • Uhm, I don't believe it is possible. – zerkms Nov 17 '10 at 03:24
  • 2
    The web browser is not involved in any step of generating URLs in your PHP application. I don't think what's happening is what you think is happening. – Dan Grossman Nov 17 '10 at 03:25
  • how can i fix this then? i have no ideas. Firefox behaves OK, IE cannot find the links. – user253530 Nov 17 '10 at 03:26
  • 1
    @user I think MS has realized that already. That doesn't necessarily mean they are able to fix it though. ;) – deceze Nov 17 '10 at 03:28
  • 1
    For the reasons everyone else is stating, it sounds IE is serving you a cached version of your site. There is no conceivable reason the HTML output of a PHP script could differ, unless you were serving user-agent conditional content on the server side. – Yahel Nov 17 '10 at 03:49
  • Can you post what the `$_SERVER` array looks like for IE and FF requests respectively? I suspect `baseUrl` depends on values in there to determine the domain and IE may not send the HOST header correctly... – deceze Nov 17 '10 at 03:57
  • Hmm, okay, at least the HTTP_HOST value is present in both cases, so that's not it. I don't know what else the `baseUrl` function depends on, and honestly I'm not willing to find any other differences in the messy array you posted. But maybe this gives you something to investigate on? – deceze Nov 17 '10 at 04:17
  • they are the same, i just checked one by one every array member. Can't understand why the host is not part of the URL in IE when i use $this->baseUrl in my layout and views. THIS HAPPENS ONLY FOR MY MODULES SO MAYBE YOU HAVE A HINT ON TWEAKING BOOTSTRAP.PHP – user253530 Nov 17 '10 at 04:19
  • If the requests are identical (on an HTTP request level), it should indeed be impossible for the app to behave differently, unless it explicitly behaves differently for different user agents. I don't know a lot about Zend, so I can't speculate any further. – deceze Nov 17 '10 at 04:34
  • Also, did you notice the "FunWebProducts" in the user agent? I believe that's a bit of adware/spyware/malware that is worth getting rid of. – Andrew M Nov 23 '10 at 10:07

4 Answers4

0

This seems to explain a similar issue:

Community
  • 1
  • 1
icyrock.com
  • 27,952
  • 4
  • 66
  • 85
0
  • php is generated on the server side, so those results are not generated by the browsers. but the result is changed by something sent to the server, like headers or the exact request address
  • I see it misses the hostname, which makes it look like an URL problem, are you sure the same address is requested in both browsers during the test?
  • $this->baseUrl() given in another reply is referring jQuery, a client side javascript library. but your code calls a php function, this may be an error if you are trying to call the jQuery function.

so,

  • it may be a URL problem; different URLs may be getting requested to display the page due to a potantial JS calling the page (an ajax function?), or it may be just the address you are typing to request the page, or different servers maybe? Eg. this can happen on some configurations when you request a page directly using the server's IP address and no domain name.
  • it may be a problem in the rest of the php code, like a problem with the session, as your FX and IE will use different sessions.
DarkWingDuck
  • 2,028
  • 1
  • 22
  • 30
  • just tried Zend_Controller_Front::getInstance()->getBaseUrl().'/admin/users'; and it behaves in the same manner on IE. so i'm guessing that my front controller doesn't initialise the baseUrl properly. I am using the same code and I have even hosted the app on a free host. Same result. IE not working, firefox has no problems. – user253530 Nov 17 '10 at 03:37
  • ok i just realized that this is only happening to my modules. My application's frontend (the default module) is working properly but the modules don't get use the same baseUrl for some strange reason. I think i need to set this up in the module's bootstrap.php. Advice? – user253530 Nov 17 '10 at 03:58
  • and this is happening only in IE. – user253530 Nov 17 '10 at 03:59
  • For more info, please give more details. How the page is called? Directly using the address bar in two browsers? Did you try to just echo the base url on a test page? This would eliminate some php specific problems. Are you trying both on the same server? Are you using a typical url with the domain name when requesting both, like 'www.mysite.com/mypage.php'? – DarkWingDuck Nov 17 '10 at 04:07
  • strangely the baseUrl looks the same in both of the browsers. – user253530 Nov 17 '10 at 04:11
  • and yes i am trying on the same server:) same address, same everything. – user253530 Nov 17 '10 at 04:13
  • Some confussions. For the server array examples, what did you exactly type into the address bar? Is there a URL rewriting? FX seems to have a referrer (forwarded from 'http://localhost/industrial/public/admin/groups'), IE does not. Request URI on FX is '/industrial/public/admin/users', and IE has an additional '/' in the end. So the address you typed is not clear. – DarkWingDuck Nov 17 '10 at 04:54
  • If you don't use the same syntax (echo $this->baseUrl) for other resource addresses like css etc, it's not really strange they load normally. In the end, it's not 'link formats', but it's the baseUrl, which doesn't show the host name when requested from IE. Also, the example lines in your question look different than each other. What does '$this' refer to? It depends on your code, but are you referring to httprequest? are you trying something like '$this->getRequest()->getBaseUrl()' ? – DarkWingDuck Nov 17 '10 at 05:05
  • To prevent any confussion, please just echo the suspected functions (echo baseUrl('...'); echo $this->baseUrl('...');) in an empty test page (no html, no 'a' tags) and see if they behave different in IE and FX – DarkWingDuck Nov 17 '10 at 05:08
  • It may be the slash in the end, which one browser may append, and one may not, try using '/' in the end of the address. – DarkWingDuck Nov 17 '10 at 05:14
  • it is not that man, you are circling around the tail. It is the fact that the Host is not inserted in the URL. in firefox (same everything so don't ask about typing the same thing) whenever i use echo $this->baseUrl('/users'); i get http://localhost/industria/users but in IE i get http:///industrial/users. DO YOU SEE THE DIFFERENCE ????? It's the same code, same URL in the address bar, same everything don't even bother to ask about that, it's not a conversation between a stupid user and an idiot guy from a call center. FFS man! – user253530 Nov 17 '10 at 13:58
  • Dear User, I'm telling the same thing, it's the host missing. 'baseUrl' depends on the requested address, and you just didn't state what the requested address was, or if there was an active URL rewriting. I was just asking to be able to further help you, because it's not clear in the question. I definetely see more differences, including only one request has a referrer and one is finishing with a '/', and your problem lies somewhere there, it's not IE, but the request and how it's handled on the server side. – DarkWingDuck Nov 17 '10 at 20:41
  • Eg. it's not clear how the expected URL is **'http://myhost/webapp_folder/public/controller/action/params'** for your code: **$this->baseUrl('/admin/users');** – DarkWingDuck Nov 17 '10 at 20:45
0

I might not be from the server. Are you sure it's not something related to: Is it recommended to use the <base> html tag? ?

Community
  • 1
  • 1
Tudor
  • 4,137
  • 5
  • 38
  • 54
0

is there a reason you need to use that for your links?

Why not just have your links:

<a href="/admin/users">Manage Users</a>

That would force the browser to append the current baseUrl by default. So if you are browsing on "www.test.com" and a page had that link, you will go to "www.test.com/admin/users" but if the same anchor tag was used on "www.test2.com" it would result in you going to "www.test2.com/admin/users"

KSolo
  • 477
  • 3
  • 11