Jump to:

23370 Posts in 18145 Topics by 2864 members

General Questions

SilverStripe Forums » General Questions » $BaseHref returns domain.com/index.php?

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 2371 Views
  • Double-A-Ron
    Avatar
    Community Member
    604 Posts

    $BaseHref returns domain.com/index.php? Link to this post

    This is only happening on our live linux server, and only with version 2.4.4 and 2.4.5.

    When $BaseHref is used in a template, the url that is generated is "http://domain.com/index.php". Therefore take the following:

    <a href="{$BaseHref}"><img src="{$BaseHref}/themes/challenger/images/Logo.png" alt="Logo Image" /></a>

    is output as follows

    <a href="http://ats.ecomcorp.co.nz/index.php/"><img src="http://ats.ecomcorp.co.nz/index.php//themes/challenger/images/Logo.png" alt="Logo Image" /></a>

    Any Ideas? This is all fine on the Windows/WAMP box.

  • swaiba
    Avatar
    Forum Moderator
    1784 Posts

    Re: $BaseHref returns domain.com/index.php? Link to this post

    mod_rewrite?

  • Ben_W
    Avatar
    Community Member
    80 Posts

    Re: $BaseHref returns domain.com/index.php? Link to this post

    This is strange, I have just built a site under ss2.4.5, and $BaseHref works fine.

    <li><a href="{$BaseHref}">Home</a></li>

    For images or css under your theme, you may try $ThemeDir (from ViewableData.php)

    <img src="/$ThemeDir/images/header.gif" width="600" height="93" border="0" alt="Header Image" />

  • leafchild
    Avatar
    Community Member
    41 Posts

    Re: $BaseHref returns domain.com/index.php? Link to this post

    I have a same issue.

    If I enter URL "mydomain.com/index.php"

    $BaseHref generate "mydomain.com/index.php" and this is messing up my other link and that results taking a user to 404 page.

  • leafchild
    Avatar
    Community Member
    41 Posts

    Re: $BaseHref returns domain.com/index.php? Link to this post

    I just found the solution here:
    http://www.silverstripe.org/general-questions/show/14405?start=8

    ============================================================
    Rather than deleting files or hacking core code - I added this to _config.php:

    <code>
    Director::setBaseURL('/');
    </code>
    ============================================================

    Withthis code, even a user access to mydomain.com/index.php, no longer mess up other link having extra "index.php"

    2371 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.