Link to home
Start Free TrialLog in
Avatar of Paul Risko
Paul RiskoFlag for United States of America

asked on

Redirect Website for Mobile Devises

If I use the following script, do I have to put it on every page and update the document.location = "mobile.html" for every page?

<script type="text/javascript">
<!--
if (screen.width <= 699) {
document.location = "mobile.html";
}
//-->
</script>

##################################################

Example would be:

Page 1

<script type="text/javascript">
<!--
if (screen.width <= 699) {
document.location = "mobile_page1.html";
}
//-->
</script>

Page 2

<script type="text/javascript">
<!--
if (screen.width <= 699) {
document.location = "mobile_page2.html";
}
//-->
</script>

Is there an easier way to redirect with .htaccess?
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

No.  .htaccess can't read the javascript that checks the screen size.
Avatar of Paul Risko

ASKER

How can I edit my question?

Any tips or guide on how to redirect a website to m.website.com are greatly appreciated.
ASKER CERTIFIED SOLUTION
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Is there anything I need to do to let Google know m.website.com is my mobile and website.com is not the mobile? Thanks.
You can join Google Webmaster Tools and submit a sitemap containing all of your pages.  https://www.wordtracker.com/academy/learn-seo/analytics/set-up-google-webmaster-tools
Any recommendation on the simplest way to send someone to the desktop site if they are emailed a link from the mobile site? I'vd found many possible solutions to this but I'm using standard HTML for the desktop site and Joomla for the mobile. Thanks.
Thanks.
Or not :(