anchor error |
[eluser]learning_php[/eluser]
Hi, I have been having trouble getting my links to work when i put my site live. it works on my localhost and everything i try does not seem to work. currently when i click a link it give a 404 error www.wesayido.co.uk. Here is my code: config: Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); controller: Code: <?PHP links in view: Code: <li><?= anchor('','Homepage');?></li> Thanks
[eluser]tomcode[/eluser]
Did not read all Your code... Your config base_url needs a trailing slash. The anchor functions have no leading slash. Which URL gives You the 404 ? EDIT : I did not use Your link ![]()
[eluser]Michael Nielsen[/eluser]
Thanks for getting married on my birthday - AWESOME! Um try auto loading your helpers and libraries instead; if I remember correctly I was once told not to load them in that first function of the class. Also try removing the leading space when you echo the links. Example: Code: <li><?=anchor('','Homepage');?></li> Not entirely sure if it's make a difference but often it's the little things.
[eluser]learning_php[/eluser]
Hi, i have changed the following: I am now autoloading the libs and helpers also edited the code below Code: $config['base_url'] = "http://www.wesayido.co.uk/"; also this is my .htaccess file i was not sure about this as the url's are being written corrrectly? Code: <IfModule mod_rewrite.c> Thanks Also if you goto the full URL the page is there: Code: http://www.wesayido.co.uk/index.php/homepage/Gifts
[eluser]TheFuzzy0ne[/eluser]
I'd suggest changing the URI protocol in your config.php to either QUERY_STRING or REQUEST_URI. Also, I'd suggest naming your controller methods in all lowercase, and calling on them in the same manner. I doubt this will make any noticeable difference, though.
[eluser]learning_php[/eluser]
Hi, I changed the controller to lowercase and the links now work! Thanks I dont think i would have ever thought of that as i had matched the case in the controller and view. Thanks again
[eluser]TheFuzzy0ne[/eluser]
As far as I know, CodeIgniter converts the controller/method names to lowercase anyway, and I think that the method names might be case sensitive. I was under the impression that PHP was not case sensitive. |
Welcome Guest, Not a member yet? Register Sign In |