Redirect script for ipad & iphone website

ProLine2k

Newbie
Joined
Dec 25, 2012
Messages
15
Reaction score
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?
 
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...
 
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...

Did you mean .htaccess? check again ;-)
 
on your cpanel dont you have redirct there?

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.
 
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...

Like I sad, I tried the .htaccess and also the script and It still not redirecting...
 
Like I sad, I tried the .htaccess and also the script and It still not redirecting...

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 :-)
 
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 :-)

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?
 
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?

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:
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.
 
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...
 
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
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.

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
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...
 
Back
Top