.htacess mobile redirect stopped working
.htacess mobile redirect stopped working -
Solution :
Additionally, if you would like to do some further testing, give the htaccess tester tool a try. It allows you to specify a certain URL as well as the rules you would like to include and then shows which rules were tested, which ones met the criteria, and which ones were executed.
.htaccess files are extremely useful in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about htaccess, redirects, mobile, , .htaccess common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your .htaccess file running smoothly.Problem :My .htaccess mobile redirect code used to work. Now it stopped working. Does anyone know why?
Here's the code:
rewritecond %HTTP_HOST ^www.anumberoneanimalandpestcontrol.com$ [OR]
rewritecond %HTTP_HOST ^anumberoneanimalandpestcontrol.com$
rewritecond %HTTP:x-wap-profile !^$ [OR]
rewritecond %HTTPS:Profile !^$ [OR]
RewriteCond %QUERY_STRING !^desktop
# if the browser accepts these mime-types, it's definitely mobile, or pretending to be
RewriteCond %HTTP_ACCEPT "text/vnd.wap.wml|application/vnd.wap.xhtml+xml" [NC,OR]
# a bunch of user agent tests
RewriteCond %HTTP_USER_AGENT "sony|symbian|nokia|samsung|mobile|windows ce|epoc|opera" [NC,OR]
RewriteCond %HTTP_USER_AGENT "mini|nitro|j2me|midp-|cldc-|netfront|mot|up.browser|up.link|audiovox"[NC,OR]
RewriteCond %HTTP_USER_AGENT "blackberry|ericsson,|panasonic|philips|sanyo|sharp|sie-"[NC,OR]
RewriteCond %HTTP_USER_AGENT "portalmmm|blazer|avantgo|danger|palm|series60|palmsource|pocketpc"[NC,OR]
RewriteCond %HTTP_USER_AGENT "smartphone|rover|ipaq|au-mic,|alcatel|ericy|vodafone/|wap1.|wap2.|iPhone|android"[NC]
rewriterule ^$ http://anumberoneanimalandpestcontrol.com/pest-control-baltimore-mobile.html[R=301,L]
I'd remove at least lines 3 through 7 because you're trying to detect very old phones with very small screens, and most mobile phones support standard HTML.
As for your rewrite rule, change:
rewriterule ^$ http://anumberoneanimalandpestcontrol.com/pest-control-baltimore-mobile.html[R=301,L]
to:
RewriteRule ^$ http://anumberoneanimalandpestcontrol.com/pest-control-baltimore-mobile.html [R=301,L]
There always needs to be one space before the first square bracket when it starts a set of RewriteRule/RewriteCond parameters such as [R=301,L].
I would suggest ditching most of your code except for lines 1, 2, and the last line and in between line 2 and the last line, add all the RewriteCond's in the apache code that you download from following this URL:
http://detectmobilebrowsers.com/
Comments
Post a Comment