开发者

Why is my server route being appended to the beginning of all my hyperlinks?

开发者 https://www.devze.com 2023-02-15 17:23 出处:网络
I have recently started messing round with CodeIgniter and ran into problems when doing standa开发者_StackOverflowrd hyperlinks through either HTML or using the anchor function, as all hyperlinks appe

I have recently started messing round with CodeIgniter and ran into problems when doing standa开发者_StackOverflowrd hyperlinks through either HTML or using the anchor function, as all hyperlinks append my server route on the start. So say for example I had written a standard hyperlink in my view such as <a href="www.testsite.com">Test site</a> it would return http://localhost/test/index.php/test/www.testsite.com when I click the link? I'm not sure what I'm doing wrong, but guessing it maybe something to do with routing?


The problem is that you have not added the protocol in front of the link in your view. Your browser is assuming that www.testsite.com is an internal link and treating it exactly the same as it would treat test/path/to/resource.php (as a relative link).

Add an http:// to the front of your URL (in the view code) and everything should just work.


It sounds like your using the url helper and adding your link ontop of the site_url() url function. Can you post your the code your using in your view?

0

精彩评论

暂无评论...
验证码 换一张
取 消