3

so I have two websites example.com and example.com/mobile , when a user visits my site on a mobile device or tablets etc I would like for them to be redirected to the mobile.example.com.

I have tried editing my .htacess file but it doesn't seem to have any effect, I have also tried adding a JavaScript in the HTML head misc scripts but to no avail.

anybody have any ideas on how i can achieve this?

2 Answers 2

3

Magento has this built-in already:

enter image description here


UPDATE:

Apologizes for missing the redirecting portion of your question, most likely you'll want to take a look at something like a lightweight php class to use in your index.php to determine such. If you can avoid the headaches of regular expressions with .htaccess, its always best.

Mobile_Detect is a lightweight PHP class for detecting mobile devices (including tablets). It uses the User-Agent string combined with specific HTTP headers to detect the mobile environment. http://mobiledetect.net

1
  • 1
    This is to pull a theme when viewed by a certain device, Not what I wanted, I wanted the site to redirect to a different store.
    – SoulEater
    Commented Oct 25, 2014 at 12:32
-1

So after messing around for a few hours, I edited the header.phtml of my theme.

Found the solution here

http://wallydavid.com/simple-php-mobile-website-redirect-code

Thanks

3
  • See my added answer reason for downvote.
    – B00MER
    Commented Oct 24, 2014 at 11:39
  • 1
    Thanks man but I'm not interested in switching themes.
    – SoulEater
    Commented Oct 25, 2014 at 12:33
  • apologizes I glazed over this detail, I've updated my original answer, hope it helps.
    – B00MER
    Commented Oct 29, 2014 at 7:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.