homepage Welcome to WebmasterWorld Guest from 54.204.231.110
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
RewriteCond help needed
Webmaster needing help with a RewriteCond
ewanfisher




msg:1507318
 4:46 pm on Jun 29, 2003 (gmt 0)

Hi all, I am having trouble with a RewriteCond rule im trying to write. So far I have the following in httpd.conf:

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

 

ewanfisher




msg:1507319
 5:25 pm on Jun 30, 2003 (gmt 0)

I have still being trying to get this to work. I enabled logging and got:
"RewriteCond: input='/zzz/messages/112/112.html' pattern='^/zzz/messages/$' => not-matched"

My RewriteCond is now "RewriteCond %{REQUEST_URI} ^/zzz/messages/$"

Any help?
Ewan

jdMorgan




msg:1507320
 5:48 pm on Jun 30, 2003 (gmt 0)

ewanfischer,

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]

Note that this is written for use in http.conf. For use or testing in .htaccess, remove the leading slash of the RewriteRule pattern.

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

ewanfisher




msg:1507321
 6:10 pm on Jun 30, 2003 (gmt 0)

Yep thats exactly what I was trying to do :)

Thanks Jim it worked perfectly!

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved