PDA

View Full Version : a bit stuck on a simple rewrite


chidge
08-16-2009, 01:26 PM
hi guys I think im just tired but I am stuck on a simple rewrite and cant work it out

simple I want to redirect anything that comes in on my home url that is a word or _


\w

and between 8 and 16 characters to a sub folder, but there are certain names that fit this description that i dont wish to redirect


so i want www.example.com/great_stuff

to go to a folder that exists in my web root called /great_stuff (as would normally happen)



and www.example.com/otherthingy

which is a folder that doesnt exist in my web root but matches the rewrite conditions of [\w]{8,16} and then redirects to

/subfolder/otherthingy but in the url shows www.example.com/otherthingy




so to redirect i have


RewriteRule ^/([\w]{8,16})/?$ /subfolder/$1/index.php [L]

but I cant get my head around how to say not redirect for the value

"otherthingy" "brilliant" "excellent" "another_one" or any others


RewriteRule ^/((^otherthingy|brilliant|excellent|another_one)[\w]{8,16})/?$ /subfolder/$1/index.php [L]


RewriteRule ^/(!(otherthingy|brilliant|excellent|another_one)[\w]{8,16})/?$ /subfolder/$1/index.php [L]

these arnt working and my logs are showing its trying to look in the subfolder redirect please can you point me in the right direction I have gone all fuzzy on this (maybe i shouldnt be trying this on a sunday)

I also have a feeling this has something to do with a rewrite condition

RewriteCond %{REQUEST_FILENAME} !-d

but if i create

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/([\w]{8,16})/?$ /subfolder/$1/index.php [L]


as i understand this says if the directory doesnt exist then perform this rule - otherwise skip it?

Bit frustrated on this and could do with some light being shed on it -Thanks in advance for any pointers