[solved]htaccess folder controller help |
[eluser]quasiperfect[/eluser]
hi i need some help related to htaccess let's say we have the controller myname and we have the folder myname is there any method i can use to send some of the request to the controller instead of the folder ? in my htaccess i have only Code: RewriteEngine On
[eluser]John Pantoja[/eluser]
I would suggest a peak at http://ellislab.com/codeigniter/user-gui...uting.html Before you go any further.
[eluser]quasiperfect[/eluser]
hmm maybe i wasn't clear. i know if i define a route i can get codeigniter to direct a request to the controller function i want but if the folder / file exists will not work. my question was how can i rewrite the request from htaccess on the server the folder myfolder exists (so the route will not work)
[eluser]John Pantoja[/eluser]
I thought there was a link for htaccess in that wiki article, the answer you seek have to deal with the RewriteCond , perhaps a google of the flags will enlighten you... or check the CI Wiki for htaccess or the place you got yours from. You'll smack yourself for this one. Eric Protip 23
[eluser]bretticus[/eluser]
My bet is putting a condition AFTER Code: RewriteCond %{REQUEST_FILENAME} !-d Since that basically tells rewrite to override your routing for a real directory (as you already know.) I think making it a part of conditions involves back references (rewrite voodoo that I've never practiced.) You might just try making an explicit rule too.
[eluser]John Pantoja[/eluser]
Yup, it's the area, I'm trying to see if he'll put a bit of effort in Google'n mod_rewrite. I'd probably put the condition he needs first if it's going to be a common thing, but it's only going to backfire in the end, needs to rename stuff to make life easier. I think CI's doc on htaccess even states exactly why he's having the problem he's having(which is no problem as mod_rewrite is doing exactly as it's told). There's no voodoo in mod_rewrite if you know your flags and some basics (maybe some Scientology though )
[eluser]quasiperfect[/eluser]
thanks for the help i got it to work added the rule Code: RewriteRule ^myfolder/(regex here)$ where to redirect [L]
[eluser]John Pantoja[/eluser]
Outstanding! I hope I wasn't coming off as a roster or anything like that. I bet it all clicked once you knew what the flags meant huh? If at all possible, try to avoid naming collisions like that as mod_rewrite does what it's told (and what order). A simple way of doing it would be: RewriteCond %{REQUEST_FILENAME} -f RewriteCond %{REQUEST_FILENAME} -d RewriteRule (.*) $1 [L] If I'm not mistaken (or it will cause a 500 error). I want to say there is a flag (in the [] area) or maybe somewhere else that will tell mod_rewrite not to rewrite it but I can't think of it at the moment.
[eluser]quasiperfect[/eluser]
@john nah. the best way is to learn how to deal with a problem in general. it was something good to read for the future form what i understand after reading the flags documentation i think the rule i used is the best my htaccess looks now like this Code: RewriteEngine On so for the myfolder case it runs until the myfolder rule and it exits there because of the [L] flag unless i'm missing something
[eluser]John Pantoja[/eluser]
Nah there's more than one way of doing it. It's just a matter preference, I myself don't use RewriteCond often. |
Welcome Guest, Not a member yet? Register Sign In |