Welcome Guest, Not a member yet? Register   Sign In
Problems using base_url
#1

[eluser]skoots[/eluser]
Newbie here.
I've set my base_url (in the config file)to

Code:
http://localhost.test/

but whenever I echo
Code:
base_url()
to link to anything the resulting request always starts with:

Code:
http://localhost.test/index.php//http//localhost.test/

I'm not using an .htaccess file. Is this something I can fix in the CI setup or am I having a server problem?

Any help would be appreciated.
#2

[eluser]Thorpe Obazee[/eluser]
if you want to link using an anchor then use anchor()

Code:
anchor()
#3

[eluser]skoots[/eluser]
Thanks for the reply. Using
Code:
anchor()
produces the same results.

For example if I try to link to a stylesheet:

Code:
<link rel='stylesheet' href='<?=base_url()?>static/css/stylesheet.css' type='text/css' />

The resulting url is:

Code:
http://localhost.test/index.php//http//localhost.test/static/css/stylesheet.css

...which obviously wont work.

Any ideas?
#4

[eluser]Thorpe Obazee[/eluser]
what happens when you echo base_url() ?
#5

[eluser]skoots[/eluser]
Frustratingly enough it's the correct url:
Code:
http//localhost.test/

But it doesn't work with the stylesheet link or if I use it like this:

Code:
<a >&lt;?php base_url($nav['path'])?&gt;Link</a>

The above results in a link that directs to:

Code:
http://localhost.test/index.php/http//localhost.test/(..etc)

So it echos properly in the code, but the links don't work (particularly with the stylesheet)

Might be an Apache thing...
#6

[eluser]Thorpe Obazee[/eluser]
[quote author="skoots" date="1241774542"]
Code:
<a >&lt;?php base_url($nav['path'])?&gt;Link</a>
[/quote]

I honestly doubt that this thing works though.

I tried to make my url like yours and it's working just fine.
#7

[eluser]skoots[/eluser]
Typo in the above code.

But take the href for the stylesheet:

Code:
&lt;link rel='stylesheet' href='&lt;?=base_url()?&gt;static/css/stylesheet.css' type='text/css' /&gt;

When I look at the source code through the browser I get:

Code:
&lt;link rel='stylesheet' href='http//localhost.test/static/css/stylesheet.css' type='text/css' /&gt;

But that href tries to load the stylesheet from http://localhost.test/index.php/http//lo...esheet.css - somehow
Code:
http://localhost.test/index.php
is included in the base_url.
#8

[eluser]skoots[/eluser]
bargainph thanks for your replies

I think I'll move on here - it's a small site so I'll hard code the links and I'll see if the problem is resolved when it's on a different server.

Seems like it may be a problem with my Apache setup.

thanks again.
#9

[eluser]Thorpe Obazee[/eluser]
It probably is a server side problem. Good luck Sad
#10

[eluser]xwero[/eluser]
skoots whate are your base_url and index settings in the config.php file




Theme © iAndrew 2016 - Forum software by © MyBB