We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

creating a mobile friendly version site

Development and Programming

bthom62's avatar
bthom62
164 posts
15 years ago
bthom62's avatar bthom62

We have just created a mobile friendly version of our site. Though I am still working to finesse it, the site looks fine on my blackberry.

Is there a way using .htaccess or something to automatically redirect iphone, blackberry users et. al to the mobile version?

Thank you

P.s. is there such thin as css for the mobile version?

       
michaelroling's avatar
michaelroling
34 posts
15 years ago
michaelroling's avatar michaelroling

You can definitely redirect mobile users via htaccess. Here’s an example:

RewriteCond %{HTTP_USER_AGENT} ^.*iPhone.*$
RewriteRule ^(.*)$ http://mobile.yourdomain.com [R=301]
RewriteCond %{HTTP_USER_AGENT} ^.*BlackBerry.*$
RewriteRule ^(.*)$ http://mobile.yourdomain.com [R=301]
RewriteCond %{HTTP_USER_AGENT} ^.*Palm.*$
RewriteRule ^(.*)$ http://mobile.yourdomain.com [R=301]

I grabbed the code from this article.

       
bthom62's avatar
bthom62
164 posts
15 years ago
bthom62's avatar bthom62

does this mean I have to make a subdomain called mobile?

my site is canadafreepress.com.index.php/article/30975

it is set to be canadafreepress.com.index.php/mobile-article/30975

with the front page being: canadafreepress.com.index.php/mobile

       
michaelroling's avatar
michaelroling
34 posts
15 years ago
michaelroling's avatar michaelroling

You don’t have to create a subdomain. You can change the rewrite rule so it hits a sub directory.

       
bthom62's avatar
bthom62
164 posts
15 years ago
bthom62's avatar bthom62

Okay thank you

so instead of mobile.example.com it would go to example.com/index.php/mobile?

obviously I have no experience with expression engine

       
michaelroling's avatar
michaelroling
34 posts
15 years ago
michaelroling's avatar michaelroling

Exactly.

       
bthom62's avatar
bthom62
164 posts
15 years ago
bthom62's avatar bthom62

I suppose there are wild cards ( I think that is what they are called, so I do not have to type out all the various templates I have that get re directed?

       
ak4mc's avatar
ak4mc
429 posts
15 years ago
ak4mc's avatar ak4mc

At Devot:ee there’s a plugin called MX Mobile Device Detect that I use to send visitors to the mobile version of my site.

       
michaelroling's avatar
michaelroling
34 posts
15 years ago
michaelroling's avatar michaelroling

There are wildcards but I’ll defer you over to Apache’s docs as you’ll probably have more questions.

Awesome find, ak4mc. This definitely appears to be the easiest way to go.

       
bthom62's avatar
bthom62
164 posts
15 years ago
bthom62's avatar bthom62

Thank you all

I am going to try the other route, and avoid the .htaccess

Thanks

       
bthom62's avatar
bthom62
164 posts
15 years ago
bthom62's avatar bthom62

Okay ….

so….

I have upload the plugin into the correct folder my next questions are…

where do I put these plugs on the template? where it says site.com do I redirect it to site.com/mobile/new tempalte?

{exp:mobile_detect location="http://m.site.com/"}

{exp:mobile_detect location="http://site.com/" redirect="not_mobile"}

{exp:mobile_detect} {if mobile} Is mobile device {/if} {if not_mobile} Is not mobile device {/if} {/exp:mobile_detect}

       
martinstasik19's avatar
martinstasik19
1 posts
2 years ago
martinstasik19's avatar martinstasik19

Thanks!

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.