Go Back   AnandTech Forums > Software > Programming

· Hardware and Technology
· CPUs and Overclocking
· Motherboards
· Video Cards and Graphics
· AMD Video Cards
· Nvidia
· Displays
· Memory and Storage
· Power Supplies
· Cases & Cooling
· SFF, Notebooks, Pre-Built/Barebones PCs
· Networking
· Peripherals
· General Hardware
· Highly Technical
· Computer Help
· Home Theater PCs
· Consumer Electronics
· Digital and Video Cameras
· Mobile Devices & Gadgets
· Audio/Video & Home Theater
· Software
· Software for Windows
· All Things Apple
· *nix Software
· Operating Systems
· Programming
· PC Gaming
· Console Gaming
· Distributed Computing
· Security
· Social
· Off Topic
· Politics and News
· Discussion Club
· Love and Relationships
· The Garage
· Health and Fitness
· Home and Garden
· Merchandise and Shopping
· For Sale/Trade
· Hot Deals with Free Stuff/Contests
· Black Friday 2015
· Forum Issues
· Technical Forum Issues
· Personal Forum Issues
· Suggestion Box
· Moderator Resources
· Moderator Discussions

Thread Tools
Old 02-06-2013, 11:18 AM   #1
Join Date: Jan 2006
Posts: 35
Default mobile site redirect with htaccess or php

I've been trying to use .htaccess for redirecting mobile users to the mobile version of my site. For two people, it doesn't seem to work.

mobile site: http://m.kracov.org

code inside .htaccess:

ErrorDocument 404 http://kracov.org/404.html

RewriteEngine On
# Check for mime types commonly accepted by mobile devices

RewriteCond %{HTTP_ACCEPT} "text/vnd.wap.wml|application/vnd.wap.xhtml+xml" [NC] RewriteCond %{REQUEST_URI} /$ RewriteRule ^  http://m.kracov.org%{REQUEST_URI} [R,L]

I also tried Mobile Detect- I searched around and someone said to put this code into the index file of my site:

$detect = new Mobile_Detect();
if ($detect->isMobile() && isset($_COOKIE['mobile']))
$detect = "false";
elseif ($detect->isMobile())
And also put the php file at the same location as the index file. But it just displays as text on my site. I'll admit I don't know what I'm doing.
INTEL I7-5820K 3.3 GHZ
Geforce GTX 970 60hz
16gb RAM
Windows 7 64 bit
Kracov is offline   Reply With Quote
Old 02-12-2013, 04:15 AM   #2
Join Date: Feb 2013
Posts: 25

Does you index file have an extension of .php or .html?

Any PHP code will output as plain text unless the file extension is ".php" (assuming the server has PHP installed to parse .php files).

Assuming the extension was ".php", and you have PHP installed, try adding the following code:
ini_set("display_errors", "on");
In your current code.

This will ensure it outputs any PHP errors, so you can report back if that happens.

The only reasons I can see this not having redirected is either
1) PHP isn't installed, so even with a .php extension it will just display it as text
2) Somewhere in the file you include, it outputs some text, which will cause header() to fail since it has to be called before any output it sent..

Let me know and I'll see if I can help some more.
watdaflip is offline   Reply With Quote

Thread Tools

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

All times are GMT -5. The time now is 01:19 PM.

Powered by vBulletin® Version 3.8.8 Alpha 1
Copyright ©2000 - 2016, vBulletin Solutions, Inc.