views:

168

answers:

3

Hi guys, I've a webapp at www.mysite.com/myapp/ and I'd like to redirect users visiting my app from iPhone to www.mysite.com/myapp/i/ using an .htaccess file in /myapp folder.

What I've tried so far is:

RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} iPhone
RewriteCond %{REQUEST_URI} !^/myapp/
RewriteRule .* /myapp/i/ [R]

It enters an infinite redirecting loop...

I understand that the problem is that the condition is verified after the redirect too, but I can't solve the problem...

Any help? Thanks guys...

A: 

try RewriteRule .* /myapp/i/ [R,L]

added:
just tried it myself. Both versions (yours and mine) work fine on my test machine. Check the log files (access.log and error.log) for messages. If you encounter problems with the rewrite module log rewrites aswell:

RewriteLog file-path
RewriteLogLevel 9
Till Backhaus
Got a 500 Internal Server Error
checcco
A: 

Try this rule:

RewriteCond $0 !^i/
RewriteCond %{HTTP_USER_AGENT} iPhone
RewriteRule .* /myapp/i/$0 [R,L]
Gumbo
A: 
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} iPhone
RewriteCond %{REQUEST_URI} !^/myapp/i/
RewriteRule .* /myapp/i/ [R]

This code in the .htaccess in the myapp folder is working perfectly...

All other answers didn't work for me...

Thanks anyway guys!

checcco