Reputation: 55
I'm new to codeIgniter. Can you tell me, how to link to other website url in codeIgniter?
I tired to do like this:
<a href="www.google.com">google</a>
But instead it gives me this
<a href="localhost/site-name/www.googlel.com">google</a>
It always refers to the base url
, even though I don't echo base_url();
on the href
.
Thanks
Upvotes: 2
Views: 89
Reputation: 4582
When creating links to external pages, you must prefix the URL with either http:// or https:// , like this:
<a href="http://www.google.com">google</a>
Technically this has little to do with CodeIgniter, but a difference between relative and absolute URLs.
If you did want to use CodeIgniter to generate the link, do this:
$this->load->helper('url');
echo anchor('http://www.google.com', 'Google');
Upvotes: 1