Welcome to WebmasterWorld Guest from 54.226.147.190

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Mod-Rewrite Issue

     

squared

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

10+ Year Member



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

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

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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

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

10+ Year Member



Great!

Jim, thanks very much for sharing.

-Squared

P.S. These forums rock!

 

Featured Threads

Hot Threads This Week

Hot Threads This Month