How to use base_url |
[eluser]ronn[/eluser]
In my config file I have the base url set up as Code: $config['base_url']="http://localhost/public/"; Code: <ul id="menu1" class="menu"> When I view the result in the webbrower it is taking out the /public/ from the URL. Why would this be? I would think the URL would look like: Code: http://localhost/public/about Code: http://localhost/about
[eluser]ronn[/eluser]
I have found a solution. I simply added echo to the statement. So that way it writes the base_url to the page. Let me know if there is still a better way.
[eluser]Twisted1919[/eluser]
For what are you doing , go with site_url('landing'); Use site_url('uri/segments') for links and base_url() for images paths,css, things like this .
[eluser]gh0st[/eluser]
Also you can use: Code: <base href="<?=base_url();?>" /> In your head, that way you don't need to put it in every time.
[eluser]Twisted1919[/eluser]
[quote author="gh0st" date="1265933558"]Also you can use: Code: <base href="<?=base_url();?>" /> In your head, that way you don't need to put it in every time.[/quote] site_url() is better because it adds suffix to your urls if it's the case , also true for index.php in front of your controller name .
[eluser]danmontgomery[/eluser]
[quote author="Twisted1919" date="1265943136"][quote author="gh0st" date="1265933558"]Also you can use: Code: <base href="<?=base_url();?>" /> In your head, that way you don't need to put it in every time.[/quote] site_url() is better because it adds suffix to your urls if it's the case , also true for index.php in front of your controller name .[/quote] http://w3schools.com/tags/att_base_href.asp |
Welcome Guest, Not a member yet? Register Sign In |