Forum Moderators: phranque
RewriteEngine on
RewriteCond %{PATH_INFO} ^/zzz/messages$
RewriteRule!^/zzz/messages/35 /zzz/messages/35/35.html [L,R]
What I am trying to do is when a user tries to access the "/zzz/messages" folder and tries to access any sub folder other than "35" they are redirected to "/zzz/messages/35/35.html"
Ewan
Form the looks of it, the problem is that you have end-anchored the pattern in the RewriteCond, and that the logic of "this directory and NOT this subdirectory" is reversed as implemented.
> What I am trying to do is when a user tries to access the "/zzz/messages" folder and tries to access any sub folder other than "35" they are redirected to "/zzz/messages/35/35.html
RewriteCond %{REQUEST_URI} !^/zzz/messages/35
RewriteRule ^/zzz/messages/ http://www.yourdomain.com/zzz/messages/35/35.html [R,L]
I'm not sure this code captures exactly what you're trying to do. Because this code implements an external redirect, it will redirect both users and internal subrequests, making only /zzz/messages/35 accessible for requests to anything in the /zzz/messages/ path. If you are just trying to establish a fixed "entry point" to your messages, you will have to add Conds which look at the HTTP_REFERER and other vars in order to allow access to other subdirs after the user enters through the proper page. Actually, without session tracking, it won't work perfectly, but you might get close enough.
HTH,
Jim