.htacces for mobile phones

Discussion in 'Apache' started by martinvidic, Jan 24, 2010.

  1. #1
    Hi everybody.
    I was trying this:

    Options +FollowSymlinks 
    RewriteEngine on
    
    RewriteCond %{HTTP_USER_AGENT} ^.*iPhone.*$
    RewriteRule ^(.*)$ http://frenchmaid.com/a.html [R=301]
    Code (markup):
    to redirect iphone users, but the rewrite rule didnt work.

    RewriteRule ^(.*)$ http://mobile.frenchmaid.com [R=301]
    Code (markup):
    on the other hand DOES work.
    Does my provider block something or is the first example simply wrong?
    THanx and regards
    Martin
     
    martinvidic, Jan 24, 2010 IP
  2. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #2
    First thing I always do when in doubt, is comment out my RewriteCond and append the variable I'm working with to a rewritten URL to take a look.

    RewriteRule ^(.*)$ http://frenchmaid.com/a.html?ua=%{HTTP_USER_AGENT}
    Code (markup):
    I'd simplify my pattern and remove the ^.* and .*$, but other than that it looks like it should work.

    It wouldn't have anything to do with your second example pointing to a different destination than the first, would it ?
     
    joebert, Jan 28, 2010 IP
  3. martinvidic

    martinvidic Guest

    Messages:
    182
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanx for the tip ( commenting out stuff )
    I simplfied it down and then found out that my server was blocking rewrite commands.
    Switched servers an now it works.
     
    martinvidic, Feb 2, 2010 IP