URI routing - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: URI routing (/showthread.php?tid=3311) |
URI routing - El Forum - 09-23-2007 [eluser]K-C[/eluser] Currently, the URL displayed as http://localhost/index.php/member/mainprofile/5. How can I display it as http://localhost/member/5? I tried using the routing but did not managed to find a way. URI routing - El Forum - 09-23-2007 [eluser]coolfactor[/eluser] You need to do 2 things: 1) use mod_rewrite (in your .htaccess file) to remove the "index.php" from the url. 2) define a custom route in your config/routes.php file that looks something like this: Code: $route['member/([0-9]+)'] = 'member/mainprofile/$1'; URI routing - El Forum - 09-23-2007 [eluser]imzyos[/eluser] yeah, quick and it works URI routing - El Forum - 09-24-2007 [eluser]K-C[/eluser] 2 scenarios :- 1. I key in http://localhost/index.php/member/1 and I got the following The URI you submitted has disallowed characters: $1 2. When I put this in the .htaccess in c:/htdocs/cmp/ RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?$1 [L] and key in http://localhost/cmp/member/1 I got redirected to web server root. URI routing - El Forum - 09-24-2007 [eluser]coolfactor[/eluser] The RewriteBase should be /cmp/ based on what you have there. URI routing - El Forum - 09-26-2007 [eluser]maesk[/eluser] Use "member/mainprofile/$1" (double quotes) instead of 'member/mainprofile/$1' to eliminate the "disallowed characters" problem. URI routing - El Forum - 09-27-2007 [eluser]K-C[/eluser] My setting is below in routes.php $route['member/([0-9]+)'] = "member/mainprofile/$1"; I am still getting this error. The URI you submitted has disallowed characters: $1 Any idea why? URI routing - El Forum - 09-27-2007 [eluser]llbbl[/eluser] Quote:RewriteEngine On Is similar to what wordpress uses. Why not use what is recommended for CI? Quote:RewriteEngine on |