Search code examples
phpcodeignitercodeigniter-urlcodeigniter-routing

CodeIgniter URI using Wildcards page not found


Explaining my situation first, I want to create a Dynamic Page using CI. I found in the URI routing that I can use WildCards, which I used it to pass an ID to a function in the controller to retrieve from the Database.

Through using my routing file [which in the routing I change which Controller and Function to Call].

1) my URL in the Default_Routing is : localhost/CI/

2) when I navigate to the other links, I would get: localhost/CI/about

3) when I use the wildcard I get this URL: localhost/CI/member/11

  • whereas I use segment(3) to get '11'

4) But while I'm in that page I try to navigate to the 'about' link again, I get: localhost/CI/member/about

  • Which somehow 'member' stays in the URL and adds 'about' after it instead of just localhost/CI/about

From the Manual I think _remap can fix that problem (which I'm not sure) and I don't how to fix this problem, or I'm using a wrong approach.


Solution

  • You have to use base_url() or site_url() functions for your links, then the links will be structured with localhost/CI/ in front.