1

I am using WordPress premium press theme website. I am using a sub-domain for mobile website m.coupontales.com, and added this code into .htaccess file:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^m\. [NC]
RewriteCond %{HTTP_USER_AGENT} !(android|blackberry|googlebot-mobile|iemobile|iphone|ipod|opera\smobile|palmos|webos) [NC]
RewriteRule ^ http://www.coupontales.com%{REQUEST_URI} [L,R=302]

But as a site admin when I go to m.coupontales.com/wp-admin, it is redirecting to www.coupontales.com. How can I block my visits ?

Mike Rockétt
  • 8,947
  • 4
  • 45
  • 81

1 Answers1

0
RewriteEngine On

# Check if this is the noredirect query string
RewriteCond %{QUERY_STRING} (^|&)noredirect=true(&|$)
# Set a cookie, and skip the next rule
RewriteRule ^ - [CO=mredir:0:%{HTTP_HOST},S]

# 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}       !^$
# Check if we're not already on the mobile site
RewriteCond %{HTTP_HOST}          !^m\.
# Check to make sure we haven't set the cookie before
RewriteCond %{HTTP:Cookie}        !\smredir=0(;|$)
# Now redirect to the mobile site
RewriteRule ^ http://m.example.org%{REQUEST_URI} [R,L]

Please follow this link Mobile Redirect using htaccess

Community
  • 1
  • 1
Pushpendra Singh
  • 182
  • 1
  • 1
  • 13