Webmaster Forum

Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.


Reply
 
Thread Tools Display Modes
Share |
  #1  
Old 10-13-2015, 03:56 AM
dinuka5525 dinuka5525 is offline
Junior Member
 
Join Date: 10-13-15
Posts: 4
iTrader: 0 / 0%
script mobile redirect does not work in mobile browser

Hi,

I am using the following script for Mobile Redirect.
Code:
RewriteEngine On RewriteCond %{QUERY_STRING} !^desktop RewriteCond %{HTTP_USER_AGENT} "android|blackberry|googlebot-mobile|iemobile|iphone|ipod|#opera mobile|palmos|webos" [NC] RewriteRule ^$ <mysite>/mobile-site[L,R=302]
This script works when a user type "http <mysite>" in mobile browser.

This script does not work when a user type "https <mysite> in mobile browser.

Please help me to redirect on both condition with http and with https.

Waiting for responses
 
Reply With Quote

Advertisement

Advertisement

  #2  
Old 10-13-2015, 10:55 AM
onthetop's Avatar
onthetop onthetop is offline
Contributing Member
 
Join Date: 01-19-15
Location: Karachi
Posts: 69
iTrader: 0 / 0%
Wink

Use this its work for me
Code:
# Check if this is the noredirect query string RewriteCond %{QUERY_STRING} (^|&)m=0(&|$) # Set a cookie, and skip the next rule RewriteRule ^ - [CO=mredir:0:www.yoursite.com] # Check if this looks like a mobile device # (You could add another [OR] to the second one and add in what you # had to check, but I believe most mobile devices should send at # least one of these headers) 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} !macintosh [NC] # 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} !(^|&)m=0(&|$) # 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.yoursite.com [R,L]
 
Reply With Quote
  #3  
Old 10-28-2015, 10:56 AM
Harr's Avatar
Harr Harr is offline
Junior Member
 
Join Date: 07-30-15
Posts: 48
iTrader: 0 / 0%
A much better option is to sign up for cloudflare for free. It's actually a CDN but it has option for mobile redirect (Both HTTP & HTTPS).
 
Reply With Quote
Go Back   Webmaster Forum > Web Development > Coding Forum

Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to make a mobile redirect mimo91 Web Design Lobby 3 04-02-2011 01:53 AM
Redirect mobile Midwifery Online Coding Forum 5 02-04-2010 03:27 PM


V7N Network
Get exposure! V7N I Love Photography V7N SEO Blog V7N Directory


All times are GMT -7. The time now is 05:17 PM.
Powered by vBulletin
Copyright 2000-2014 Jelsoft Enterprises Limited.
Copyright © 2003 - 2018 VIX-WomensForum LLC