Email:support@eranet.com WhatsApp:+(852)68882160

How to Make the M Subdomain for Mobile Websites

  • Release time:2013-10-14

  • Browse:4122

  • Other People Are Reading

                Google Analytics Subdomain Instructions            

                                                                                                                                                                                                                               

     

    An increasing number of people surf the Internet using a mobile device, such as a smart phone or a tablet. Website owners can choose to either make their sites resize based on screen size or send mobile visitors to a separate version of the website that is optimized for phones. Creating an “m” subdomain for the phone-optimized version of your site is a good way to separate it from the main site, but you need to also redirect mobile visitors to the subdomain. Detecting screen size is a simple way to tell mobile browsers to redirect to the subdomain.

     

     

    Eranet Link:  ICANN Accredits Registrar, Get one .cn domain at $17.96/yr with free DNS here

     

    Domain names have the lowest price:

    .cn.com  only USD 1.99/year

    .pw        only USD  1.99/year

    .asia     only  USD  2.99/year

    .com    only  USD  9.99/year

    .cn       only   USD 17.96/year

    .hk       only   USD 28/year      

     

    hk domain name & cn domain hot sale!

     

     

    Make a Subdomain
    1
    Log into the control panel for your Web hosting account. Click the “Subdomains” icon, which is often grouped with other domain-related tools.

    2
    Type “m” in the subdomain field. Select the domain you want to add the subdomain to, using the dropdown list.

    3
    Take note of the FTP location where your new subdomain's files will go. This information typically displays on the subdomain creation page as soon as you enter the subdomain's name. Submit the form to create your subdomain. The subdomain should go live right away, but you must upload files to it before anything will appear there.


    Write the Redirect
    4
    Open the file for your website's home page, which is usually “index.html” or “index.php.” If there are no “<head>” tags in that file, open the heading file, typically named “header.html” or “header.php.”

    5
    Add “<script>” tags above the closing “</head>” tag in your home page's code:

    <script type=”text/javascript”>
    </script>

    6
    Write a small JavaScript to detect the screen width of the device being used to visit your website. If the screen width is less than 700 pixels, you can assume the user is visiting your website on a mobile device. In this case, redirect the user to the “m” subdomain:

    <script type=”text/javascript”>
    if (screen.width <= 699) {
    document.location = “http://m.yourdomain.com/”;
    }
    </script>

    In the above script, change “yourdomain.com” to your own domain.

     

Search

Document