Anchor links do not work |
[eluser]variouspixels[/eluser]
can anyone help me? If I go to http://localhost/index.php/site/index or http://localhost/ I can see my homepage as expected. I set the following on relevant page. Code: $config['index_page'] = ""; The problem: http://localhost/about does not work My anchor links in header_view.php do not work either. Code: <?= anchor('/about', 'About', array('title' => 'About')); ?> My code: Code: class Site extends Controller { Hope this make sense. Noob here. many thanks
[eluser]mddd[/eluser]
If you request /about, that means you are looking for the controller called About. That is not the case, you need the controller called Site and the METHOD called about. So that would be /site/about. If you want /about to refer to this, you could make a rule that says Code: $route['about'] = 'site/about'; What you need to realize, is that the 'default controller' route will only work if there is no controller requested. That means: if the user asks for '/'. THEN the default controller kicks in. But if you give a url, the default controller does not activate.
[eluser]steelaz[/eluser]
Did you setup your .htaccess file (http://ellislab.com/codeigniter/user-guide/general/urls.html)? Are you testing on Linux or Windows system?
[eluser]variouspixels[/eluser]
@mddd I have changed the link to site/about but still no change. @steelaz I am using MAMP locally atm. I have not added a .htaccess file. I will try find the correct rule to fix my problem. thanks
[eluser]flaky[/eluser]
Code: http://localhost/about Code: http://localhost/index.php/site/about Code: <?= anchor('site/about', 'About', array('title' => 'About')); ?>
[eluser]Ivar89[/eluser]
If you don't have a htaccess file you need index.php so; http://localhost/index.php/about
[eluser]variouspixels[/eluser]
@ivar89 links are working fine now I have set Code: $config['index_page'] = "index.php"; I will need to remove the index.php/site from the url though. I guess I use .htaccess instead of changing any codeigniter parameters.
[eluser]variouspixels[/eluser]
Removed index.php succesfully by adding relevant htaccess file. Enabled http://localhost/about and http://localhost/contacts pages to work correctly by following advice from mddd. However, my CSS files no longer work and I cannot figure out why. Any ideas?
[eluser]steelaz[/eluser]
It's possible that you configured .htaccess file incorrectly. Can you open your css file by entering url in a browser?
[eluser]variouspixels[/eluser]
No I cannot. 404 .htaccess Code: RewriteEngine on |
Welcome Guest, Not a member yet? Register Sign In |