How To block pc user to view my site url and view my site Only mobile

Started on the old forum in August 2011 · view the original in the archive · old links redirect here

13 replies · 1,248 views · started 15 years ago · 1 min read

TL;DR · summary of 13 replies
  • kolkatawap wanted to block PC users from viewing his website URL, while only allowing mobile users to access the site.
  • Anthony suggested adding a function at the top of the index page to redirect PC users to a "NOT WELCOME MESSAGE" and mobile users to their mobile site.
  • kolkatawap was unsure about where to place the code for notphone.php or if they needed to create a separate .php file, as opposed to including it in main index.php.
  • metulj stated that blocking PC users from viewing his site is impossible, implying this solution might not work universally.

Written automatically from the replies by a language model on our own server. It can be wrong; the posts below are the source.

7 participants
kolkatawap Junior · 18 posts #1

How To block pc user to view my site url and view my site Only mobile plz help

Added after 5 minutes:

Plz guide me the easiest way look it http://www.wapday.com this site only visible for mobile user but if u browse it on pc it show open it 4m mobile just i want the same thing for my url

Anthony Developer · 82 posts #2

kolkatawap wrote: How To block pc user to view my site url and view my site Only mobile plz help

Added after 5 minutes:

Plz guide me the easiest way look it http://www.wapday.com this site only visible for mobile user but if u browse it on pc it show open it 4m mobile just i want the same thing for my url

Add this function to the very top of your index page

<?php //////GYSMS.com Browser Detection $mobile_browser = '0'; if(preg_match('/(up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone)/i', strtolower($_SERVER['HTTP_USER_AGENT']))){ $mobile_browser++; } if((strpos(strtolower($_SERVER['HTTP_ACCEPT']),'application/vnd.wap.xhtml+xml')>0) or ((isset($_SERVER['HTTP_X_WAP_PROFILE']) or isset($_SERVER['HTTP_PROFILE'])))){ $mobile_browser++; } $mobile_ua = strtolower(substr($_SERVER['HTTP_USER_AGENT'],0,4)); $mobile_agents = array( 'w3c ','acs-','alav','alca','amoi','audi','avan','benq','bird','blac', 'blaz','brew','cell','cldc','cmd-','dang','doco','eric','hipt','inno', 'ipaq','java','jigs','kddi','keji','leno','lg-c','lg-d','lg-g','lge-', 'maui','maxo','midp','mits','mmef','mobi','mot-','moto','mwbp','nec-', 'newt','noki','oper','palm','pana','pant','phil','play','port','prox', 'qwap','sage','sams','sany','sch-','sec-','send','seri','sgh-','shar', 'sie-','siem','smal','smar','sony','sph-','symb','t-mo','teli','tim-', 'tosh','tsm-','upg1','upsi','vk-v','voda','wap-','wapa','wapi','wapp', 'wapr','webc','winw','winw','xda','xda-'); if(in_array($mobile_ua,$mobile_agents)){ $mobile_browser++; } if (strpos(strtolower($_SERVER['ALL_HTTP']),'OperaMini')>0) { $mobile_browser++; } if (strpos(strtolower($_SERVER['HTTP_USER_AGENT']),'windows')>0) { $mobile_browser=0; } if($mobile_browser>0){ header("Location: http://www.yourmobilesite.com"); } else{ header("Location: http://www.yoursite.com/notphone.php"); } ?>

FREE International SMS

GYSMS.com Provides FREE International sms Reach over 775 networks in more than 221 countries at no cost to you. and the Good News is we own our SMS Hardware so there is no third party SMS API involved our services are completely Ad supported.....

http://gysms.com

Send FREE International MMS and Share Files worldwide using our MMS Service.

http://gysms.net

GTriddim Live Online Radio Station

http://www.gtriddim.com

kolkatawap Junior · 18 posts #3

Thanks but what is there i just copy and paste the code in top of my index page but what is there yoursite.com/notphone.php is it mysiteurl/notphone.php i have to make

Anthony wrote: Add this function to the very top of your index page

Added after 10 minutes:

Brother My site name is Index of / may i copy your whole code and paste top of my index page or make a file such.php and include function at top of my index page

Anthony Developer · 82 posts #4

kolkatawap wrote: Thanks but what is there i just copy and paste the code in top of my index page but what is there yoursite.com/notphone.php is it mysiteurl/notphone.php i have to make

Added after 10 minutes:

Brother My site name is Index of / may i copy your whole code and paste top of my index page or make a file such.php and include function at top of my index page

bro where it says

if($mobile_browser>0){

header("Location: http://www.yourmobilesite.com"); } else{ header("Location: http://www.yoursite.com/notphone.php");

}

You have to replace with the url of your site

if($mobile_browser>0){

header("Location: http://www.willme.in/mobile.php"); } else{ header("Location: http://www.willme.in/notphone.php");

}

You have to create a page where you want to display a message to the web browsers

FREE International SMS

GYSMS.com Provides FREE International sms Reach over 775 networks in more than 221 countries at no cost to you. and the Good News is we own our SMS Hardware so there is no third party SMS API involved our services are completely Ad supported.....

http://gysms.com

Send FREE International MMS and Share Files worldwide using our MMS Service.

http://gysms.net

GTriddim Live Online Radio Station

http://www.gtriddim.com

metulj Super moderator Principal · 1,726 posts #5

kolkatawap wrote: How To block pc user to view my site url and view my site Only mobile plz help

Added after 5 minutes:

Plz guide me the easiest way look it www.wapday.com this site only visible for mobile user but if u browse it on pc it show open it 4m mobile just i want the same thing for my url

you can't block PC to browse on your site ! simple as that

It's better to keep your mouth shut and give the impression that you're stupid, than to open it and remove all doubt. ⓣⓗⓔ ⓠⓤⓘⓔⓣⓔⓡ ⓨⓞⓤ ⓑⓔ©ⓞⓜⓔ, ⓣⓗⓔ ⓜⓞⓡⓔ ⓨⓞⓤ ⓐⓡⓔ ⓐⓑⓛⓔ ⓣⓞ ⓗⓔⓐⓡ ! ιη тнєσяу, тнє ρяα¢тι¢є ιѕ α яєѕυℓт σƒ тнє тнєσяу, вυт ιη ρяα¢тι¢є ιѕ тнє σρρσѕιтє.

キノgんイノ刀g 4 ア乇ムc乇 ノ丂 レノズ乇 キucズノ刀g 4 √ノ尺gノ刀ノイリ!

Anthony Developer · 82 posts #6

metulj wrote: you can't block PC to browse on your site ! simple as that

He wants to redirect PC users to a "NOT WELCOME MESSAGE" and Mobile Phones to his mobile site.

FREE International SMS

GYSMS.com Provides FREE International sms Reach over 775 networks in more than 221 countries at no cost to you. and the Good News is we own our SMS Hardware so there is no third party SMS API involved our services are completely Ad supported.....

http://gysms.com

Send FREE International MMS and Share Files worldwide using our MMS Service.

http://gysms.net

GTriddim Live Online Radio Station

http://www.gtriddim.com

kolkatawap Junior · 18 posts #8

Brother i couldn't find the way Plz help i have copy and paste all code u mention here in a notphone.php file and place <?php include("notphone.php")/>;in my main index.php- is it such way i need to do or other way

metulj Super moderator Principal · 1,726 posts #9

kolkatawap wrote: Brother i couldn't find the way Plz help i have copy and paste all code u mention here in a notphone.php file and place <?php include("notphone.php")/>;in my main index.php- is it such way i need to do or other way

kolkatawap wrote: Search google best place ever

i wonder why you are asking questions here ?

It's better to keep your mouth shut and give the impression that you're stupid, than to open it and remove all doubt. ⓣⓗⓔ ⓠⓤⓘⓔⓣⓔⓡ ⓨⓞⓤ ⓑⓔ©ⓞⓜⓔ, ⓣⓗⓔ ⓜⓞⓡⓔ ⓨⓞⓤ ⓐⓡⓔ ⓐⓑⓛⓔ ⓣⓞ ⓗⓔⓐⓡ ! ιη тнєσяу, тнє ρяα¢тι¢є ιѕ α яєѕυℓт σƒ тнє тнєσяу, вυт ιη ρяα¢тι¢є ιѕ тнє σρρσѕιтє.

キノgんイノ刀g 4 ア乇ムc乇 ノ丂 レノズ乇 キucズノ刀g 4 √ノ尺gノ刀ノイリ!

Anthony Developer · 82 posts #10

kolkatawap wrote: Brother i couldn't find the way Plz help i have copy and paste all code u mention here in a notphone.php file and place <?php include("notphone.php")/>;in my main index.php- is it such way i need to do or other way

bro send me a email so i can do this for you since you are having a hard time understanding my previous post : admin[at]gysms.com

FREE International SMS

GYSMS.com Provides FREE International sms Reach over 775 networks in more than 221 countries at no cost to you. and the Good News is we own our SMS Hardware so there is no third party SMS API involved our services are completely Ad supported.....

http://gysms.com

Send FREE International MMS and Share Files worldwide using our MMS Service.

http://gysms.net

GTriddim Live Online Radio Station

http://www.gtriddim.com

Framework Newbie · 3 posts #11

metulj wrote: you can't block PC to browse on your site ! simple as that

wrong wml can be seen only by phone and opera , operamini there are redirect codes to send mobile browsers into certain page and pc users to send them into another certain page.

metulj Super moderator Principal · 1,726 posts #12

Framework wrote: wrong wml can be seen only by phone and opera , operamini there are redirect codes to send mobile browsers into certain page and pc users to send them into another certain page.

what you are babbling about ?

It's better to keep your mouth shut and give the impression that you're stupid, than to open it and remove all doubt. ⓣⓗⓔ ⓠⓤⓘⓔⓣⓔⓡ ⓨⓞⓤ ⓑⓔ©ⓞⓜⓔ, ⓣⓗⓔ ⓜⓞⓡⓔ ⓨⓞⓤ ⓐⓡⓔ ⓐⓑⓛⓔ ⓣⓞ ⓗⓔⓐⓡ ! ιη тнєσяу, тнє ρяα¢тι¢є ιѕ α яєѕυℓт σƒ тнє тнєσяу, вυт ιη ρяα¢тι¢є ιѕ тнє σρρσѕιтє.

キノgんイノ刀g 4 ア乇ムc乇 ノ丂 レノズ乇 キucズノ刀g 4 √ノ尺gノ刀ノイリ!

WASEEM Newbie · 4 posts #13

Nice This is Worked in my site but i want to add this code in thead.php how i can set? its mean i want to set or unset from my site admin panel

pyramid_raider Developer · 60 posts #14

pc users cannot be blocked to view ur site.. it can be still viewed by changing user agent.. simple option is make one page for pc and another for mobile8)

Write your reply now; next you create a free account (or sign in) and it is posted right away. Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close