1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Redirect script for ipad & iphone website

Discussion in 'General Scripting Chat' started by ProLine2k, Dec 27, 2012.

  1. ProLine2k

    ProLine2k Newbie

    Joined:
    Dec 25, 2012
    Messages:
    15
    Likes Received:
    0
    I am really frustrated with trying to redirect my website to a mobile version site. I have done with the .hitaccess redirect code, but for some reason I cannot get it to work again. I tried a dozen of different codes and also I?ve tried using the script code on the html index page but they are just not redirecting!!! I?ve mess-up my server and now my website is offline? still waiting for technical support to get it back online.
    This is what I?m trying to do. I have a flash website and I want to redirect my site to an iPhone page and an iPad page that I created.
    I?m using this code on the .hitaccess (777)

    1[SUP]st[/SUP] Question: Do I need to create a sub-domain in order to redirect? Or I can have the redirect point directly to its real location

    2[SUP]nd[/SUP] Question: The best way to redirect should be using a code on the .hitaccess file or thru a script code on the <head> of the html index file? I?ve tried the code and still not redirecting.

    Thank you very much for any help and suggestion on this matter. The more I read I get frustrated, it should be something simple but I cannot figure out why it?s not working?
     
  2. carrepairs12

    carrepairs12 BANNED BANNED

    Joined:
    Jun 7, 2009
    Messages:
    326
    Likes Received:
    236
    on your cpanel dont you have redirct there?
     
  3. Gogol

    Gogol Elite Member

    Joined:
    Sep 10, 2010
    Messages:
    3,066
    Likes Received:
    2,872
    Gender:
    Male
    First Answer: Create a subdomain from your cpanel.
    Second Answer: Redirecting via htaccess is better because Apache is much faster than server side code. So your site redirects faster. If you use redirect from you header, then make sure you first use the 301 header, or it won't be a permanent redirect. If you need more info, post a reply here...
     
  4. Gogol

    Gogol Elite Member

    Joined:
    Sep 10, 2010
    Messages:
    3,066
    Likes Received:
    2,872
    Gender:
    Male
    Did you mean .htaccess? check again ;-)
     
  5. ProLine2k

    ProLine2k Newbie

    Joined:
    Dec 25, 2012
    Messages:
    15
    Likes Received:
    0
    Yes, cpanel has the redirect but I need a working script that detects the mobile device first in order to redirect to a second iPhone version of my website.
     
  6. ProLine2k

    ProLine2k Newbie

    Joined:
    Dec 25, 2012
    Messages:
    15
    Likes Received:
    0
    Like I sad, I tried the .htaccess and also the script and It still not redirecting...
     
  7. Gogol

    Gogol Elite Member

    Joined:
    Sep 10, 2010
    Messages:
    3,066
    Likes Received:
    2,872
    Gender:
    Male
    Make sure you have a file called .htaccess in your root directory, not .hitaccess.. If you already do, post you apache rule here. I will help you out :)
     
  8. ProLine2k

    ProLine2k Newbie

    Joined:
    Dec 25, 2012
    Messages:
    15
    Likes Received:
    0
    I have the file .htaccess on my public_html directory with the permission set to 777.
    As far as apache rule, I have no idea what that is. Sorry, I'm newbie. Can you help me please?
     
  9. Gogol

    Gogol Elite Member

    Joined:
    Sep 10, 2010
    Messages:
    3,066
    Likes Received:
    2,872
    Gender:
    Male
    i.e. , what did you write in your htaccess file for the redirection?

    Edit: seems like you did not redirect your subdomain to your folder correctly...

    if that's not the case then wrting this rule will do your job cleanly (given you have mod_rewrite enabled) :
    Code:
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^m\.example\.com$
    RewriteRule ^ http://example.com/m%{REQUEST_URI} [L,301]
    
    What server do you use? Does it have cpanel ( that will make your job easier)?
     
    Last edited: Dec 27, 2012
  10. ProLine2k

    ProLine2k Newbie

    Joined:
    Dec 25, 2012
    Messages:
    15
    Likes Received:
    0
    I have tried that same code before. Still not working... I created a sub-domain called mobi and I have set permission to the .htaccess file to 777. My pages are hosted on BigBytes net.

    Question: Inside the folder for the sub-domain "mobi" there is another .htaccess file, do I need to have the same code on that file? Thank you. Much appreciated for your help.
     
  11. ProLine2k

    ProLine2k Newbie

    Joined:
    Dec 25, 2012
    Messages:
    15
    Likes Received:
    0
    By the way, I don't need just a redirection code. I need a code that detects an iPhone, iPad, iPod first them redirects to the mobile version of the website. Thanks...
     
  12. Gogol

    Gogol Elite Member

    Joined:
    Sep 10, 2010
    Messages:
    3,066
    Likes Received:
    2,872
    Gender:
    Male
    I guess you are using CPanel am i right? If you have CPanel, then go to "Add a subdomain", name your sub-domain and point it to a folder in your server. You won't need any additional code for the redirection, as because the server handles it itself. Here's the cpanel documentation for adding a subdomain:
    Code:
    http://docs.cpanel.net/twiki/bin/view/AllDocumentation/CpanelDocs/SubDomains#Add a Subdomain
    That's a totally different scenario. to be able to do redirection for different OS and browsers, you need to sniff the user agent string.
    Here's a good tutorial on that:
    Code:
    http://www.9lessons.info/2010/09/redirect-mobile-devices-with-php.html