Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

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

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

$BaseHref returns domain.com/index.php?


Go to End


5 Posts   4156 Views

Avatar
Double-A-Ron

Community Member, 607 Posts

14 April 2011 at 4:35pm

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.

Avatar
swaiba

Forum Moderator, 1899 Posts

14 April 2011 at 7:04pm

mod_rewrite?

Avatar
Ben_W

Community Member, 80 Posts

28 April 2011 at 12:39pm

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" />

Avatar
leafchild

Community Member, 41 Posts

7 October 2011 at 6:04pm

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.

Avatar
leafchild

Community Member, 41 Posts

7 October 2011 at 6:17pm

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"