Results 1 to 4 of 4

Thread: baseUrl view helper returns empty string

  1. #1
    sawatdee is offline Member
    Join Date
    Mar 2008
    Posts
    40

    Default baseUrl view helper returns empty string

    I am using Zend Framework 1.10.2 and the baseUrl view helper always returns an empty string no matter what my original request URL was.

    I don't think this is related to ZF-9091, because the suggested solution already exists in the version of Zend/Controller/Request/Http.php that I have.

    I don't think my .htaccess could be the problem as the contents are:
    Code:
    RewriteEngine On
    RewriteBase /
    RewriteRule !\.(js|ico|gif|jpg|png|css|jar|pdf|doc|wav|mp3)$ index.php
    I know that not all servers are configured to set the same server variables, so maybe baseUrl doesn't work in all cases. So my question is......

    Does anyone know if baseUrl has known issues (meaning I need to find a work-around)? Or is this a bug in my version or the result of a problem that can easily be solved?
    Last edited by sawatdee; 04-26-2010 at 01:58 AM. Reason: spelling

  2. #2
    alokin is offline Senior Member
    Join Date
    Apr 2009
    Posts
    211

    Default

    Yes, base url can be empty. For example, if you have ZF site on your server, which is placed in folder "foo", and main entry point - index.php is in the root of that "foo" folder, then base url will be empty string.

  3. #3
    sawatdee is offline Member
    Join Date
    Mar 2008
    Posts
    40

    Default

    Quote Originally Posted by alokin View Post
    Yes, base url can be empty. For example, if you have ZF site on your server, which is placed in folder "foo", and main entry point - index.php is in the root of that "foo" folder, then base url will be empty string.
    I get an empty string even if I go to one of the other controllers. For example, if I go to www.mysite.com/some_module/some_controller baseUrl still returns an empty string.

  4. #4
    BugFixBug is offline Member
    Join Date
    Dec 2009
    Posts
    69

    Default

    i believe baseUrl() gives your the baseUrl not the uri part your in right now.

    if you would not have your application index in / of your domain but for instance in /my-test-project/ you can tell zf that this part is not a module/controller etc but its part of the root path. so it will skip that part when checking for route setc

    so if you dont set the base path it could return an empty string.

    in your config you can set this as following:
    resources.frontController.baseUrl = "/subdir"

Similar Threads

  1. Zend_Controller_Response_HttpTestCase::getHeaders returns an empty array
    By sawatdee in forum Model-View-Controller (MVC)
    Replies: 0
    Last Post: 05-30-2010, 12:17 PM
  2. Load view from string variable?
    By zxc in forum General Q&A on Zend Framework
    Replies: 1
    Last Post: 04-09-2009, 12:38 AM
  3. [Zend_Form} getMessages returns empty array
    By PanGuzol in forum General Q&A on Zend Framework
    Replies: 1
    Last Post: 02-24-2009, 01:39 AM
  4. Retrive ACL from an action helper by a view helper
    By Arjuna in forum Authentication & Authorization
    Replies: 2
    Last Post: 11-16-2008, 03:50 PM
  5. baseUrl in View helper?
    By Snef in forum Model-View-Controller (MVC)
    Replies: 0
    Last Post: 09-09-2007, 09:02 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •