+ Reply to Thread
Results 1 to 3 of 3

Thread: Confused about base URL...

  1. #1
    mehaase is offline Junior Member
    Join Date
    Aug 2008
    Posts
    4

    Default Confused about base URL...

    I'm new to ZF, and I'm working on a project where we have a deployable application. In most cases the application will live in a document root (http://host/index.php), and I understand that part of it.

    But we are contemplating what would happen if a user tried to install in a subdirectory, such as http://host/username/index.php

    It seems to me that if I set the RewriteBase to /username, then ZF will automatically rewrite all of the URLs in the application; for example, if I link to /controller/action in this example, ZF will rewrite that link to /username/controller/action. Is that correct?

    Assuming the above is correct, then here's my question: How do I handle links to non-script files? Assume that I'm using a rewrite rule like this:

    Code:
    Alias /username /path/to/my/doc/root
    RewriteEngine on
    RewriteBase /username
    RewriteRule !\.(js|ico|gif|jpg|png|css)$ index.php
    If I have a page that links to /styles/main.css, ZF will not process that request because Apache won't rewrite the request to the front controller. What's the solution here?

    Hopefully this is clear... we're having a debate among our developers how best to handle this. Some are convinced that ZF's native handling will work fine, and others are convinced that we need to prepend the base URL to every link that we create (which means modifying thousands of lines of code). I'm a ZF newbie so I have no idea but I'm trying to research it.

    Thanks,

  2. #2
    jcarouth's Avatar
    jcarouth is offline Junior Member
    Join Date
    Sep 2007
    Location
    College Station, TX
    Posts
    6

    Default

    You don't have to prepend the base URL to your links because apache will handle the request as it would if you had a static site in that directory (or alias as it may be). The RewriteBase only comes into play because the alias you are using does not correspond to a physical path on the server.

  3. #3
    askjoo is offline Junior Member
    Join Date
    Jun 2009
    Posts
    1

    Default

    The way I am currently rerouting image paths for my view files are

    echo "<img src='" . $this->baseUrl() . "/images/funnyforum.jpg'/>";

    where baseURL is

    class Zend_View_Helper_BaseUrl
    {
    function baseUrl()
    {
    $fc = Zend_Controller_Front::getInstance();
    return $fc->getBaseUrl();
    }
    }

    do you know if this is the best way to do this?

+ Reply to Thread

Similar Threads

  1. Confused about setting up routing
    By mbira in forum Installation & Configuration
    Replies: 0
    Last Post: 05-22-2010, 05:13 AM
  2. Confused with Domain and Service in DDD
    By Juan in forum General Q&A on Zend Framework
    Replies: 0
    Last Post: 02-06-2010, 12:01 AM
  3. confused about sessions ..
    By manojsingh in forum General Q&A on Zend Framework
    Replies: 3
    Last Post: 02-15-2009, 02:30 AM
  4. Confused about Models
    By kellyg1 in forum Model-View-Controller (MVC)
    Replies: 1
    Last Post: 08-26-2008, 07:48 AM
  5. Confused with routing
    By cmerlin in forum General Q&A on Zend Framework
    Replies: 5
    Last Post: 07-25-2008, 06:24 AM

Posting Permissions

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