开发者

htaccess : redirect an iphone user unless

I've been reading up on the syntax for constructing htaccess rules but no matter what I try, I can't get to do what I want to do.

I am aiming to redirect all iphone visitors to a subfolder on my domain, easy enough:

RewriteCond %{HTTP_USER_AGENT} iPhone
RewriteCond %{REQUEST_URI} !^/iphone
RewriteRule .* http://domain.com/iphone/ [R]

This successfully redirects iphone users who aren't already trying to go to http://domain.com/iphone. However, I don't want to redirect users who are trying to go to domain.com/app (this url has its own redirect to an apple app store page, so i want iphone users to be redirected there as well, rather than the ip开发者_开发百科hone version of my site). I tried this:

RewriteCond %{HTTP_USER_AGENT} iPhone
RewriteCond %{REQUEST_URI} !^/app
RewriteCond %{REQUEST_URI} !^/iphone
RewriteRule .* http://domain.com/iphone/ [R]

I thought that the /app condition should work in parallel with the /iphone condition, but it seems iphone visitors to domain.com/app are still being redirected to munch5aday.com/iphone/.

Very grateful for any suggestions!


Add the line RewriteEngine off to the directory's .htaccess file.

Adding answer now to avoid this question being listed as unanswered. Answer is based on questioner's comment in December 2010.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜