Redirect "/" to "/home"? |
[eluser]kyleect[/eluser]
I'm trying to figure out what to add to my htaccess to redirect "/" to "/home" but to complicate things, the app may not be in the root directory. It could be a sub directory, like this: http://localhost/app/ to http://localhost/app/home I have tried looking at mod_rewrite tutorials but still can't get it to work. This is what I've tried. RewriteRule ^/$ /home Which, does nothing. Please help!
[eluser]srisa[/eluser]
You can set up "home" as your default controller and CI will redirect '/' to /home/index.
[eluser]kyleect[/eluser]
home is my default now, and that works but I want an actual redirect. This would be similar to how some people redirect www.domain.com to just domain.com
[eluser]Unknown[/eluser]
There is a redirect function in one of the CI helpers. Can't remember whcih, but it's there.
[eluser]Pascal Kriete[/eluser]
It's in the url helper (which is a good one to autoload ![]() Edit: Re-reading your post, for anything outside CI you will need to use mod_rewrite of course.
[eluser]kyleect[/eluser]
I know but I don't know the mod_rewrite to do it. Does anyone know the mod_rewrite to do this?
[eluser]darkhouse[/eluser]
I don't know if this would work, and this might be a "hacky" solution, but what if you wrote a library like this: Code: class Home_redirect { and then autoloaded that library? Again, I didn't test it, but it might do what you need without using mod_rewrite.
[eluser]kyleect[/eluser]
I would prefer to do this with mod_rewrite, keeping it as "clean" as possible.
[eluser]darkhouse[/eluser]
I agree it's a dirty solution and htaccess is the way to go (if possible). I would use this as a last resort myself.
[eluser]garrettheel[/eluser]
Code: RewriteEngine On |
Welcome Guest, Not a member yet? Register Sign In |