Mobile redirect with .htaccess for www.example.com OR example.com -


I am going to start the mobile version of my website soon, already have set up space for it:

I found a solution here:

^ It works fine when I try this with my iphone4 Only if I enter www in the URL. If I leave it then I get my regular site.

So I need mobile redirects if the user enters www.example.com or example.com

I have made some modifications in the code and it is working almost is. Now it works for both versions of the URL but I have to refresh once to get the mobile site. Obviously I want to work for redirection when they first arrive at the site. I'm sure I'm missing something here, tell me what you think. My host is aplus.net as BitDream.

  rewrite% {HTTP_HOST} ^ (www \ .example \ .com> example. Com) [nc] rewritecand% {HTTP_USER_AGENT} "Android | blackberry | iphone | ipod | iMobile | opera Mobile | pamose | webos | googlebot-mobile "[nc] rewriteual ^ (. *) $ Http://mobile.example.com/$1 [L, R = 302]   

John Response to Lynn ...

Yes, there are some other rules in my .htaccess

defining various index types:

  directory index Index.html index.htm INDEX. HTML INDEX.HTM index index index .htm default.htm default .htm index.shtml index.cgi index.php index.php3 index.jsp index.phtml   

.php extension from url Deleting

  Options + Multivisable rewriteignin rewritecode% {REQUEST_FILENAME}! -f Rev. Raul ^ ([^ \. + +) $ $ 1.php [NC, L]   

Then here the CP which was automatically inserted from:

  # [CP global redirection - get started] & lt; IfModule mod_rewrite.c & gt; RewriteEngine at RewriteCond% {SERVER_PORT}! ^ 443 $ rewrite% {SERVER_NAME}! ^ Www \ .. * $ RewriteRule ^ (. *) $ Http: //www.% {SERVER_NAME} / $ 1 [R] rewrite% {SERVER_PORT}} ^ $ 443 $ rewrite% {SERVER_NAME}! ^ Www \ .. * $ rehabilitation rule ^ (. *) $ Https: //www.% {SERVER_NAME} / $ 1 [R] & lt; / IfModule & gt; # [CP global redirection - termination]    

Below we use mobile redirect code For our mobile applications, our Appliances.net platform should be able to use it to redirect it to its own custom site.

  RewriteEngine RewriteBase / RewriteCond at% {REQUEST_URI}! ^. * [^ /] $ RewriteCond% {REQUEST_URI}! ^. * $ * $ RewriteCond% {REQUEST_METHOD}! POST RewriteCond% {QUERY_STRING}! * *. * Rewrite% {HTTP: X-WAP-PROFILE}! ^ $ [OR] rewritec% {http: PROFILE}! ^ $ [Or] rewrite% {HTTP_USER_AGENT} ^. * (Alcatel | ASUS | Android | Blackberry | Ericsson | Fly | Havai | I-MAT | IPAQ | iPhone | IPOD | LG- | LG | | MDS- | MOT- | Nokia | Palm | Panasonic | Pentec | Phillips | Saigeam | Samsung | Sharp | SIE- | Symbian | Vodafone | Voxetel | WebOS | Windows + SE | ZTE- | Zune] * $ [nc, or] rewrite% {HTTP_ACCEPT} application /vnd.wap.xhtml\+xml [NC, OR] RevertCand% {HTTP_ACCEPT} text / vnd.wap.wml [NC] Rewrite angle% {SERVER_PORT}! ^ 443 $ rewrite% {SERVER_NAME} ^ www. (. *.) $ RewriteRule ^ (. *) Http: //mobile.%1/ [L] RewriteCand% {REQUEST_URI}! ^. * [^ /] $ Rewrite% {REQUEST_URI}! ^. * // * $ RewriteCond% {REQUEST_METHOD}! POSTReportCand% {QUERY_STRING} !. * =. * Rewrite% {HTTP: X-WAP-PROFILE}! ^ $ [Or] rewritec% {http: PROFILE}! ^ $ [Or] rewrite code% {HTTP_USER_AGENT} ^. * (Alcatel | ASUS | Android | Blackberry | Ericsson | Fly | Hevei | I-MAT | IPAQ | iPhone | iPod | LG- | LGE- | MDS_ | MOT- | Nokia | Palm | Panasonic | Pantech | Phillips | Sagem | Samsung | Sharp | SIE- | Symbian | Vodafone | Voxtel | WebOS | Windows \ s + CE | ZTE- | Zune). * $ [Nc, or] rewrite% {HTTP_ACCEPT} application / vnd.wap.xhtml \ + xml [NC, or] rewrite% {HTTP_ACCEPT} text / vnd.wap.wml [nc] rewritable ^ (. *) Http: //mobile.% {HTTP_HOST} / [L]    

Comments