You have to use base_url() or site_url() functions for your links, then the links will be structured with localhost/CI/ in front.
CodeIgniter URI using Wildcards page not found
-
26-06-2022 - |
Question
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
OTHER TIPS
maybe create virtual host for CI folder!
go -> C:\Windows\System32\drivers\etc\host add line -> 127.0.0.1 localhost localhost2 localhost3
then go to webserver httpd.conf file and add:
<VirtualHost localhost2>
ServerName localhost2
DocumentRoot "C:/wamp/www/project2"
<Directory "C:/wamp/www/project2">
allow from all
order allow,deny
AllowOverride All
</Directory>
</VirtualHost>
<VirtualHost localhost3>
ServerName localhost3
DocumentRoot "C:/wamp/www/CI"
<Directory "C:/wamp/www/CI">
allow from all
order allow,deny
AllowOverride All
</Directory>
</VirtualHost>
Restart webserver! And now to view your CI folder type in browser -> loaclhost3