Re: Struggling with Apache 2.0.54 & mod_rewrite

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 10/7/07, Shaun T. Erickson <sterickson@xxxxxxxxx> 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.
-- 
        -ste

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx


[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux