.htaccess for multiple controllers |
[eluser]VirtualDevel[/eluser]
Hey guys, I have two main controllers, the site controller and the admin controller. I want to setup the htaccess file to remove the index.php from the url string. However, when I do it, it works fine for site but redirects to site for admin requests. Request: http://localhost/ => go to controllers/main Request: http://localhost/admin => go to controllers/admin Code: <IfModule mod_rewrite.c> config.php: Code: $config['index_page'] = "";
[eluser]VirtualDevel[/eluser]
bump, anyone? I think I would need to add something to the routes or htaccess?
[eluser]Pascal Kriete[/eluser]
Try adding a question mark behind the index.php in the two rewrite rules: Code: RewriteRule ^(.*)$ index.php?/$1 [L] Let me know if that works.
[eluser]Phil Sturgeon[/eluser]
Thats not the problem you are having. Is main a controller that you want all frontend url's to go through, or is it meant to be your default route? If you just want / to go to controllers/main then set it in your config/routes.php to do so. If you want all url's other than /admin to go to the controller/main, you will need to say so in your redirect rule, as it is currently JUST removing the index.php and not saying anything about main. Code: <IfModule mod_rewrite.c> This has not been tested as im at work, but should be pretty close. I removed the systems.* condition as you should not be typing system into the URL - unless your index.php file is inside that folder (bad idea).
[eluser]Pascal Kriete[/eluser]
@pyro I can see where you're coming from - I still believe his problem is much simpler as per the last statement: Quote:it works fine for site but redirects to site for admin requests. I guess we'll have to see what comes back ![]()
[eluser]Phil Sturgeon[/eluser]
That last post I made was total tosh! I updated the rule to something mice nicer. Everything I removed from your htaccess was not being used and never would be.
[eluser]VirtualDevel[/eluser]
Nope, still no go.. No matter what I do I cant seem to get routed to the admin controller. When I browse to domain.com/admin, the url says domain.com/admin but domain.com/index.php/main/index is executed, what I need is domain.com/index.php/admin. Funny enough, when I go to domain.com/index.php/admin this works. Thanks. directory structure: Quote:ControllersThanks.
[eluser]VirtualDevel[/eluser]
As a side not, I have tried creating an admin.php directly under the controllers folder and still nothing. Thanks, really appreciate the input!
[eluser]VirtualDevel[/eluser]
Ok, weird, and this is probably silly of me. I tried it on the dev server and it works fine! However, on my person machine it fails, I'm using xampp for my web server and mysql. I'll try and upgrade to the latest versions and check the confs. Thanks a ton guys! ![]()
[eluser]VirtualDevel[/eluser]
HA! I'm an idiot, I had mod_rewrite commented out! Thanks a ton guys, really helped a lot.. |
Welcome Guest, Not a member yet? Register Sign In |