Help with simple routing please? |
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
Do the one thing you think you cannot do. Fail at it. Try again. Do better the second time. The only people who never tumble are those who never mount the high wire.
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?
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.
Do the one thing you think you cannot do. Fail at it. Try again. Do better the second time. The only people who never tumble are those who never mount the high wire.
I'm using _remap instead of custom routes with routes.php, this method give me more wave of customization.
NexoPOS 2.6.2 available on CodeCanyon.
Thanks, I will have to look into that. But for now I guess I will just read more on rewrite rules.
Do the one thing you think you cannot do. Fail at it. Try again. Do better the second time. The only people who never tumble are those who never mount the high wire.
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]
Do the one thing you think you cannot do. Fail at it. Try again. Do better the second time. The only people who never tumble are those who never mount the high wire.
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';
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.
Do the one thing you think you cannot do. Fail at it. Try again. Do better the second time. The only people who never tumble are those who never mount the high wire.
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.
Do the one thing you think you cannot do. Fail at it. Try again. Do better the second time. The only people who never tumble are those who never mount the high wire.
|
Welcome Guest, Not a member yet? Register Sign In |