homepage Welcome to WebmasterWorld Guest from 54.196.62.132
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

    
Mod-Rewrite Issue
squared




msg:1505931
 7:39 pm on Aug 8, 2002 (gmt 0)

A friend of mine set-up mod-rewrite for me. I told him that I wanted NS4 users to get a special page and for all other browsers to get the normal one. However, the code that he put in does this for every directory, and I only wanted the root directory to do this. The code is:

RewriteCond %{HTTP_USER_AGENT} ^Mozilla/4.*
RewriteCond %{HTTP_USER_AGENT} !^.*MSIE.*
RewriteCond %{REQUEST_URI} !^.*ns_.*\.html
RewriteRule ^(.*\.html)$ ns_$1 [L]

Does anyone know what would need to be changed so that this only happens in the current directory (or for that matter the root directory)? I think it's the last line that needs to be changed, but am afraid if I do something it might screw it up.

Any insight?

-Squared

 

jdMorgan




msg:1505932
 8:29 pm on Aug 8, 2002 (gmt 0)

Squared,

This should limit the redirect to acting only in your top-level directory.

RewriteCond %{HTTP_USER_AGENT} ^Mozilla/4.*
RewriteCond %{HTTP_USER_AGENT} !^.*MSIE.*
RewriteCond %{REQUEST_URI} !^.*ns_.*\.html
RewriteRule ^([^/]\.html)$ ns_$1 [L]

Take a look at this handy primer on regular expressions [etext.lib.virginia.edu].

Hope this helps,
Jim

<edit>... And welcome to WebmasterWorld! </edit>

squared




msg:1505933
 11:39 pm on Aug 8, 2002 (gmt 0)

Great!

Jim, thanks very much for sharing.

-Squared

P.S. These forums rock!

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