-
Notifications
You must be signed in to change notification settings - Fork 446
- Download the CMS sample https://github.com/bcosca/fatfree/blob/archive/f3-3.0.1.cms.demo.zip
- Looking for more usage examples? Take a look at the Framework Unit Tests. There you'll find lots of code samples of the built-in features.
- Join us at #fatfree on freenode IRC network. Use Webchat now!
- We have an active community in Google Groups f3-framework
- Post questions in Stack Overflow fat-free-framework if that's your preference.
Static method calling convention has been deprecated. It will be dropped in the next major version.
Static method calling convention has been deprecated. It will be dropped in the next major version.
Well, best practice is to run F3 on your own virtual host, so that it's always the root of your domain. But in some cases, when working on a server, where F3 is not located in the web root, i.e. on shared webhosting services, where you possibly don't have the choice to setup vhosts or for testing purpose, you might need some extra workarounds.
Let's say F3 runs in mydomain.com/myapp/. Maybe you think you need to update your .htaccess file now and add a RewriteBase /myapp
, but as long as the .htaccess file is also located where the index.php is, you don't need to add it, because the server will take the current path as Base by default.
But you will notice some weird behaviours with your pagelinks.
When you are on mydomain.com/myapp/page1/ and click a link like <a href="page2/">
, it goes to mydomain.com/myapp/page1/page2/ instead of the desired mydomain.com/myapp/page2/. Well you could add a leading slash to your links like /page2/
, but then it becomes an absolute link that goes to mydomain.com/page2/ and fixing that by adding the app-path to each link in your template, like href="/myapp/page2/"
, just feels crappy.
The solution to this is using the HTML Tag. Just add it in the head section of your template, like <base href="myapp/">
(with tailing slash). Your links will now behave correctly. Unfortunately the Internet Explorer browser only supports absolute paths as base href value. But adding <base href="http://mydomain.com/myapp/">
is not that comfortable, as you might need (switching dev and live server, http / https). So, to get a bit sugar on this, KOTRET was so friendly and wrote this little snippet, that automatically computes the absolute base path. Just put that in a Utils class and add <base href="{{ Utils::getBaseUrl() }}">
to your template. Now it's fine. The base tag also affects CSS links you might have used in a relative way, like background-image: url(../img/page_bg.jpg)
. They are also working like expected now.