![]() |
url rewrite problem - 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: url rewrite problem (/showthread.php?tid=11103) |
url rewrite problem - El Forum - 08-26-2008 [eluser]RpR[/eluser] Hi, I am facing this problem. I have a controller called welcome.php which is called as the index page. Thanks to the url rewrite I have a clean url like this: Code: http://localhost/cvp/ Code: http://localhost/cvp/index.php Now when I add another function (Like test) in welcome.php the url is Code: http://localhost/cvp/welcome/test/ Is there a way to remove the welcome to? My current htaccess file is: Code: RewriteEngine on Thanks for any input. url rewrite problem - El Forum - 08-26-2008 [eluser]Derek Allard[/eluser] You bet. Set your config['index_page'] to '' (empty quotes) and use CI's anchor() function. url rewrite problem - El Forum - 08-26-2008 [eluser]RpR[/eluser] It is blank. It needs to be blank for the rewrite. url rewrite problem - El Forum - 08-26-2008 [eluser]Derek Allard[/eluser] and the anchor funtion is automatically adding in "welcome"? Could you share your code? url rewrite problem - El Forum - 08-26-2008 [eluser]LuckyFella73[/eluser] If you have a fresh installation of codeigniter where the default controller in routes.php is still set to "welcome" and you load the page, the first URI segment is not displayed (I don't know how CI hides it). As soon you click at a link, the controller name is displayed as URI segment 1 and the function name is added as URI segment 2 (if you call any other function then index). In your case Code: http://localhost/cvp/welcome/test Code: http://localhost/cvp/test you will have to add a controller named "test" (controller/test.php with the class name "Test" Did you mean that? url rewrite problem - El Forum - 08-26-2008 [eluser]fesweb[/eluser] I think you're looking for "routes" functionality. In your config/routes.php file: Code: $route['test/:any'] = "welcome/test/"; Something like that should do it. url rewrite problem - El Forum - 08-26-2008 [eluser]RpR[/eluser] Shall test this but then I loose the ability to add it on the fly. Then I should edit 2 files. The main controller class and then the routes file. url rewrite problem - El Forum - 08-26-2008 [eluser]fesweb[/eluser] You can also remap the controller, which gives a different result, but you might be able to think your way into a solution which works for you. First function after the _constructor(): Code: if ($method == 'index') |