httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shaun T. Erickson" <>
Subject [users@httpd] Re: Struggling with Apache 2.0.54 & mod_rewrite
Date Sun, 07 Oct 2007 19:11:29 GMT
On 10/7/07, Shaun T. Erickson <> wrote:
> I have been scratching my head over this for hours ...
> I'm trying accomplish this:
> If the UserAgent is not ABCD, and the request is for either /dir1/ or
> /dir1-test/ then it should be rewritten to /dir1/info/
> The idea is that only UAs of ABCD should get served the index file in
> /dir1/ or /dir1-test/ and all others should get served the index file
> in /dir1/info/ instead.
> Additionally, if the UA is not ABCD and they explicitly request the
> index file by name, in either directory, they should also get
> redirected to /dir1/info/
> It isn't clear to me whether the directives belong in /.htaccess or in
> /dir1/.htaccess and /dir1-test/.htaccess and I'm still struggling to
> come up with the right directives as well.
> There are already .htaccess files in /dir1/ and /dir1-test/ that
> define what the index file for that directory is, and that works fine.
> The index file in the info dir is just index.html.

I came up with this, which works:

RewriteEngine On

RewriteCond %{HTTP_USER_AGENT} CFNetwork [OR]
RewriteCond %{HTTP_USER_AGENT} AppTapp
RewriteRule ^iphone-apps-test/$ iphone-apps-test/repo.cache [L]
RewriteRule ^iphone-apps-test/$ iphone-apps/info/ [L]

RewriteCond %{HTTP_USER_AGENT} CFNetwork [OR]
RewriteCond %{HTTP_USER_AGENT} AppTapp
RewriteRule ^iphone-apps/$ iphone-apps/repo.cache [L]
RewriteRule ^iphone-apps/$ iphone-apps/info/ [L]

I am wondering if there is anyway to collapse this further, however.

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