![]() |
Mobile Redirect PHP Help
Ok, I am taking advice from Nicky(I think) and redirecting my mobile traffic to m.mydomain.com before I send it off to wherever I want to.
The problem I am having for some reason is getting the m.mydomain.com to redirect. I want to use a php redirect from one location for all of my sites. So I am using: <?php @ini_set('expose_php', 'Off'); @include "http:location of the php file";?> in the index.php of the m.mydomain.com. I want to be able to change the url at the "location of the php file" one time and it changes it on every site I have. For some reason when I try it its not working. I am using this in the "location of the php file": <?php /* Redirect browser */ header("Location: final redirected URL"); /* Make sure that code below does not get executed when we redirect. */ exit; ?> Where am I going wrong? Thanks |
You mean include('file'); not include 'file' right?
|
Oh, and you are including the FILE PATH, not some http:// path, right?
|
So you want whatever hits m.oneofyourdomains.com to redirect to the same url?
Forget the include mess and use 1 index.php and point all your m.allyourdomains.com to the directory index.php is in. |
Quote:
|
Quote:
Quote:
|
Quote:
|
Quote:
He didn't go into any details. I took it to mean that google may penalize the site if your just rerouting traffic off your site as soon as they get there but if you route them through a sub domain your main site doesnt get penalized. But he didn't say that, I inferred it from what he recommended. |
I just did a soft 302 redirect from the server to the spot I have the url I want to direct the surfer to.
Works fine. If there is a better way to do it I am all ears. Otherwise I will just do it this way. |
Sorry, I went to bed when I didn't see a reply from you. Do the path to the file on your server, i.e.:
require_once('includes/file.php'); (replace your include line with that) |
Quote:
On a side note I have to say I feel a little stupid about this but I want to place: RewriteCond %{HTTP_USER_AGENT} (mobile|android|blackberry|brew|cldc|docomo|htc|j2 me|micromax|lg|midp|mot|motorola|netfront|nokia|ob igo|openweb|opera.mini|palm|psp|samsung|sanyo|sch| sonyericsson|symbian|symbos|teleca|up.browser|voda fone|wap|webos|windows.ce) [NC] RewriteRule ^(.*)$ http://m.myurl.com [R=302,L] RewriteCond %{HTTP_USER_AGENT} (GoogleTV) [NC] RewriteRule ^(.*)$ http:myurl.com [R=302,L] in the htaccess but when I do my site goes 500. Where exactly should I place this in my wordpress htaccess file? |
Quote:
|
Quote:
|
Quote:
|
Quote:
|
You can use this as the index.php for your m.domain.com, and there's really nothing wrong with using the include this way.
Instead of redirecting from the included file, just use it to populate the url you want to redirect to. INDEX.PHP for your mobile domains Code:
<?php MOBILE.INI or whatever you decide to call it. Code:
http://redirectmymobiletraffichere.com |
If you use dropbox, one interesting way of managing this could be to create/edit a file like mobile.ini (or other name) in your Dropbox Public folder. It'd look something like:
http://dl.dropbox.com/u/3782156/mobile.ini It'd be a file on your computer, but also mirrored to Amazon's Cloud. You still just make that 1 change to a file anytime you want, and all your mobile sites will read it and redirect to the new location. Could be an interesting strategy for managing your simple data like this for other uses. Maybe even add a simple cache layer, to cache the file in your TMPDIR with an expire time like 15 mins. |
|
Quote:
|
All times are GMT -7. The time now is 11:10 AM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123