title: htaccess too many redirects on iphones
body: <p>I have an issue with my htaccess causing too many redirects on a Joomla site on ONLY safari (iphones), works fine on android and i am using the same code on another website which is not joomla and it works fine. Here is the code for the redirect.  Again this is Joomla.</p>
  
  <p>Here is the redirect code:</p>
  
  <pre><code>RewriteEngine on
  RewriteBase /
  
  # Check if this is the noredirect query string
  RewriteCond %{QUERY_STRING} (^|&amp;)m=0(&amp;|$)
  # Set a cookie, and skip the next rule
  RewriteRule ^ - [CO=mredir:0:http://glotfeltytire.net/]
  
  RewriteCond %{HTTP_HOST} ^glotfeltytire.net
  RewriteRule .* - [L]
  
  RewriteCond %{HTTP:x-wap-profile} !^$ [OR]
  RewriteCond %{HTTP:Profile}       !^$ [OR]
  RewriteCond %{HTTP_USER_AGENT} "acs|alav|alca|amoi|audi|aste|avan|benq|bird|blac|blaz|brew|cell|cldc|cmd-" [NC,OR]
  RewriteCond %{HTTP_USER_AGENT} "dang|doco|eric|hipt|inno|ipaq|java|jigs|kddi|keji|leno|lg-c|lg-d|lg-g|lge-" [NC,OR]
  RewriteCond %{HTTP_USER_AGENT}  "maui|maxo|midp|mits|mmef|mobi|mot-|moto|mwbp|nec-|newt|noki|opwv" [NC,OR]
  RewriteCond %{HTTP_USER_AGENT} "palm|pana|pant|pdxg|phil|play|pluc|port|prox|qtek|qwap|sage|sams|sany" [NC,OR]
  RewriteCond %{HTTP_USER_AGENT} "sch-|sec-|send|seri|sgh-|shar|sie-|siem|smal|smar|sony|sph-|symb|t-mo" [NC,OR]
  RewriteCond %{HTTP_USER_AGENT} "teli|tim-|tosh|tsm-|upg1|upsi|vk-v|voda|w3cs|wap-|wapa|wapi" [NC,OR]
  RewriteCond %{HTTP_USER_AGENT} "wapp|wapr|webc|winw|winw|xda|xda-" [NC,OR]
  RewriteCond %{HTTP_USER_AGENT} "up.browser|up.link|windowssce|iemobile|mini|mmp" [NC,OR]
  RewriteCond %{HTTP_USER_AGENT} "symbian|midp|wap|phone|pocket|mobile|pda|psp" [NC]
  RewriteCond %{HTTP_USER_AGENT} "iphone|ipod" [NC,OR]
  
  # Check if we're not already on the mobile site
  RewriteCond %{HTTP_HOST}          !^m\.
  # Can not read and write cookie in same request, must duplicate condition
  RewriteCond %{QUERY_STRING} !(^|&amp;)m=0(&amp;|$) 
  
  # Check to make sure we haven't set the cookie before
  RewriteCond %{HTTP_COOKIE}        !^.*mredir=0.*$ [NC]
  
  # Now redirect to the mobile site
  RewriteRule ^ http://m.glotfeltytire.net [R,L]
  </code></pre>
  
  <p>This is the Joomla code:</p>
  
  <pre><code>########## Begin - Rewrite rules to block out some common exploits
  ## If you experience problems on your site block out the operations listed below
  ## This attempts to block the most common type of exploit `attempts` to Joomla!
  #
  ## Deny access to extension xml files (uncomment out to activate)
  #&lt;Files ~ "\.xml$"&gt;
  #Order allow,deny
  #Deny from all
  #Satisfy all
  #&lt;/Files&gt;
  ## End of deny access to extension xml files
  # Block out any script trying to set a mosConfig value through the URL
  RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
  # Block out any script trying to base64_encode data within the URL
  RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
  # Block out any script that includes a &lt;script&gt; tag in URL
  RewriteCond %{QUERY_STRING} (&lt;|%3C)([^s]*s)+cript.*(&gt;|%3E) [NC,OR]
  # Block out any script trying to set a PHP GLOBALS variable via URL
  RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
  # Block out any script trying to modify a _REQUEST variable via URL
  RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
  # Return 403 Forbidden header and show the content of the root homepage
  RewriteRule .* index.php [F]
  #
  ########## End - Rewrite rules to block out some common exploits
  
  
  ########## Begin - Custom redirects
  #
  # If you need to redirect some pages, or set a canonical non-www to
  # www redirect (or vice versa), place that code here. Ensure those
  # redirects use the correct RewriteRule syntax and the [R=301,L] flags.
  #
  ########## End - Custom redirects
  
  
  #  Uncomment following line if your webserver's URL
  #  is not directly related to physical file paths.
  #  Update Your Joomla! Directory (just / for root)
  
  # RewriteBase /
  
  
  ########## Begin - Joomla! core SEF Section
  #
  RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
  #
  # If the requested path and file is not /index.php and the request
  # has not already been internally rewritten to the index.php script
  RewriteCond %{REQUEST_URI} !^/index\.php
  # and the request is for root, or for an extensionless URL, or the
  # requested URL ends with one of the listed extensions
  RewriteCond %{REQUEST_URI} (/[^.]*|\.(php|html?|feed|pdf|raw))$ [NC]
  # and the requested path and file doesn't directly match a physical file
  RewriteCond %{REQUEST_FILENAME} !-f
  # and the requested path and file doesn't directly match a physical folder
  RewriteCond %{REQUEST_FILENAME} !-d
  # internally rewrite the request to the index.php script
  RewriteRule .* index.php [L]
  #
  ########## End - Joomla! core SEF Section
  </code></pre>