Help with simple routing please? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Help with simple routing please? (/showthread.php?tid=62134) |
Help with simple routing please? - lexxtoronto - 06-12-2015 Routing is my weak point, Im still not clear how it works although I read the docs many times. Anyhoo. This is my .htaccess file Code: <IfModule mod_rewrite.c> This is my controller: Code: class Tlc extends CI_Controller And this is my routes.php Code: $route['default_controller'] = "tlc/view"; I have my view files in views/tlc folder. When you go to main page deltadigital.ca - everything is fine, but when you click deltadigital.ca/about-us or other similar menu items it doesnt work. It only works with full url i.e. http://deltadigital.ca/index.php/tlc/view/about-us RE: Help with simple routing please? - roopunk - 06-12-2015 I just compared with your rewrite rules with the ones that I am using. This particular line, I am using $0 instead of $1 RewriteRule .* index.php?/$0 [PT,L] Can you try this and see if it works? RE: Help with simple routing please? - lexxtoronto - 06-12-2015 Nope, still doesn't work, but thanks anyway as I at least I know where to look for a problem. I tried this: Code: RewriteRule ^(.*)/index/?$ $1 [L,R=301] And instead of 500 server it's just giving me my webhost 404 page, which is a good sign I guess. RE: Help with simple routing please? - Blair2004 - 06-13-2015 I'm using _remap instead of custom routes with routes.php, this method give me more wave of customization. RE: Help with simple routing please? - lexxtoronto - 06-13-2015 Thanks, I will have to look into that. But for now I guess I will just read more on rewrite rules. RE: Help with simple routing please? - lexxtoronto - 06-15-2015 Still can't make it work. What are my options now? Do I just hardcode it in .htaccess similar to this? Code: RewriteRule ^pet-care/?$ pet_care_info_01_02_2008.php [NC,L] RE: Help with simple routing please? - mwhitney - 06-15-2015 You original .htaccess should be fine. In your routes, though, the second one doesn't look quite right: Code: $route['/([a-z]+)'] = "tlc/view/$1"; You may want to remove the slash (/) in the route key: Code: $route['([a-z]+)'] = 'tlc/view/$1'; or to :any: Code: $route['(:any)'] = 'tlc/view/$1'; RE: Help with simple routing please? - lexxtoronto - 06-15-2015 Thank you, but still no luck. I tried both: Code: $route['([a-z]+)'] = 'tlc/view/$1'; and $route['(:any)'] = 'tlc/view/$1'; And also tried removing it altogether, doesnt work. Also if I use the rewrite rule without a leading slash its giving me 500 server error Code: RewriteRule ^(.*)$ index.php?/$1 [L,QSA] If I use it with a slash its giving me my webhosts 404 Code: RewriteRule ^(.*)$/index.php?/$1 [L,QSA] I tried other modifications of this rule online and it would give me CI 404 page. RE: Help with simple routing please? - lexxtoronto - 06-15-2015 It was a problem with 1and1 host. So FIY 1and1 not good for Codeigniter. I tried a different host and it works just fine. I can't believe I wasted so much valuable time. |