httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Denise Mangano" <>
Subject [users@httpd] Apache/2.2.9, RH Enterprise, mod_rewrite, RewriteRule not working as expected
Date Mon, 16 Feb 2009 18:56:49 GMT

I am having some difficulties with the Rewrites in my apache config.
I've been at this for a couple of weeks now and I admit I am having a
very difficult time with the syntax.  I've read the mod_rewrite
documentation as well as the URL rewriting guide, but nothing I try
seems to be working.  I am now behind in my project so I caved and need
to reach out to the pros for help =) 

I've searched the mailing list archives but can't seem to find my exact
situation.  I have a web site -  I am trying to
configure my apache to redirect all mobile users to  I
can get that part of it to work easily.  However, the problem is that
there are about a hundred subdirectories under and for
mobile users I need to redirect them to the same subdirectory on I would prefer not to have to write out a RewriteRule for
each subdirectory because we are constantly adding more every day and
maintenance is a bear.

requests for get redirected to
requests for gets redirected to
requests for gets redirected to

The following is in my httpd.conf (I came across this suggestion based
on one of my google search):
   #Redirect Mobile users by exclusion
   RewriteCond %{HTTP_USER_AGENT}  !^.*Linux.*$ [NC]
   RewriteCond %{HTTP_USER_AGENT}  !^.*Win.*$ [NC,OR]
   RewriteCond %{HTTP_USER_AGENT}  ^.*Windows\s+CE.*$ [NC]
   RewriteCond %{HTTP_USER_AGENT}  !^.*OS\s+(X|9).*$ [NC]
   RewriteCond %{HTTP_USER_AGENT}  !^.*Solaris.*$ [NC]
   RewriteCond %{HTTP_USER_AGENT}  !^.*BSD.*$ 
   RewriteRule ^/$ [R]

My site by default always looks for index.html.  So this works great -
requests for are properly forwarded to the
VirtualHost I have set up for and it services the mobile
version of index.html that I have there.  Now I needed to modify the
Rewrite rule to tackle the subdirectories.

Based on my internet searches I've tried to change my RewriteRule to the
   RewriteRule ^/(.*)$1 
This actually does redirect to the same subdirectory on the mobile
Virtual Host, so I believe I got at least half of it right.  I requested and was properly redirected to
However, it is taking  ALL requests to and forwards it
to even the non-mobile users.  This is confusing me
greatly since the RewriteCond by exclusion worked fine before - it
appears that suddenly the condition tests are failing.

Any advice/help anyone can offer is greatly appreciated.  Thanks in
Denise Mangano

The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:> for more info.
To unsubscribe, e-mail:
   "   from the digest:
For additional commands, e-mail:

View raw message