2
Hello! I’ll be very brief. I’m having trouble defining a correct href="". After clicking a link in the menu, it is directing to the HOSTGATOR page '404 - page not found' Here’s the controller code:
class Posts extends CI_Controller {
//Página de listar posts
public function index()
{
// Carrega o model posts
$this->load->model('posts_model', 'posts');
// Criamos a array dados para armazenar os posts
// Executamos a função do posts_model getPosts
$data['posts'] = $this->posts->getPosts();
// Carregamos a view listarprodutos e passamos como parametros a array posts que guarda todos os posts
// da db posts
$this->load->view('listarposts', $data);
}
// Página de listar reiki
public function reiki()
{
// Carrega a model posts
$this->load->model('posts_model', 'posts');
// Carrega a view
$this->load->view('listarreiki');
}
}
Here goes the view with href with the link:
<ul class="list-unstyled">
<li><a href="posts/reiki">Reiki</a></li>
</ul><span class="heading">Email</span>
I am learning the codeigniter now and using it for a website I am developing. Would you have to modify in Routes.php or autoload.php? Could someone help me.
No need to add the route. How the url is
post/reiki
and the class ispost
, methodreiki
, CI will recognize. Anything you can add/posts/reiki
. Maybe you are entering a URL that doesn’t really exist. You can also check the.htaccess
(if your server is apache) https://gist.github.com/philipptempel/4226750– Valdeir Psr
You can activate the url helper and use
base_url('posts/reiki')
. It may also be that the removal of index.php solve the case.– ShutUpMagda
I made all the changes that commented, but nothing helped. Still pointing to page not found.
– Rodrigo Souza Jesus