GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Mobile Redirect PHP Help (https://gfy.com/showthread.php?t=1062473)

PornHustler 03-26-2012 06:42 PM

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

edgeprod 03-26-2012 06:44 PM

You mean include('file'); not include 'file' right?

edgeprod 03-26-2012 06:45 PM

Oh, and you are including the FILE PATH, not some http:// path, right?

u-Bob 03-26-2012 06:48 PM

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.

PornHustler 03-26-2012 09:25 PM

Quote:

Originally Posted by u-Bob (Post 18846335)
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.

Whenever anyone goes to the "m" mobile sub domain of any site I have I want to be able to reroute them to another url. But I want to be able to control all of the redirecting from one spot. Change one link and they all change.

PornHustler 03-26-2012 09:36 PM

Quote:

Originally Posted by edgeprod (Post 18846327)
You mean include('file'); not include 'file' right?

It was the path to the php file in a folder on one of my domains.

Quote:

Originally Posted by edgeprod (Post 18846329)
Oh, and you are including the FILE PATH, not some http:// path, right?

I wasn't but I can do that.

Jakez 03-26-2012 09:49 PM

Quote:

Originally Posted by PornHustler (Post 18846324)
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.

Care to elaborate or quote what he said?

PornHustler 03-26-2012 09:54 PM

Quote:

Originally Posted by Jakez (Post 18846536)
Care to elaborate or quote what he said?

I think it was him, he said something like take his word for it to route the mobile traffic from your site to a subdomain and then to the the destination.

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.

PornHustler 03-26-2012 10:18 PM

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.

edgeprod 03-26-2012 10:22 PM

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)

PornHustler 03-26-2012 10:27 PM

Quote:

Originally Posted by edgeprod (Post 18846564)
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)

I tried that. It didnt work. I tried a couple different ways. Nothing worked except the 302.

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?

edgeprod 03-26-2012 10:29 PM

Quote:

Originally Posted by PornHustler (Post 18846569)
I tried that. It didnt work. I tried a couple different ways. Nothing worked except the 302.

What didn't work about it? It didn't include the file? That's only as far as I read that cringe-inducing code. I couldn't bring myself to go deeper, LOL.

PornHustler 03-26-2012 10:32 PM

Quote:

Originally Posted by edgeprod (Post 18846571)
What didn't work about it? It didn't include the file? That's only as far as I read that cringe-inducing code. I couldn't bring myself to go deeper, LOL.

When I included the php file where the end url is in the "m.mysite.com" the broswer doesnt follow the new url. In other words the site never redirects. If I go right to the file in my browser I am redirected and everything is fine.

edgeprod 03-26-2012 10:49 PM

Quote:

Originally Posted by PornHustler (Post 18846574)
When I included the php file where the end url is in the "m.mysite.com" the broswer doesnt follow the new url. In other words the site never redirects. If I go right to the file in my browser I am redirected and everything is fine.

There are ways to check why that's happening (whitespace, accidental headers, etc), but if you're content with the 302, that seems to be enough.

Jakez 03-28-2012 11:38 AM

Quote:

Originally Posted by PornHustler (Post 18846540)
I think it was him, he said something like take his word for it to route the mobile traffic from your site to a subdomain and then to the the destination.

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.

Hm, I dunno, I've been doing a 302 htaccess redirect for a few years now and it's never hurt the PC or mobile SE that I get..

Brujah 03-28-2012 11:53 AM

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
$redirect = file_get_contents( 'http://somedomain.com/mobile.ini' );
header( 'Location: ' . trim( $redirect ) );
exit();
?>

Wherever somedomain.com is, just create the file mobile.ini there. You can call it whatever you want, but all it will contain is a url. No php code or other necessary.

MOBILE.INI or whatever you decide to call it.
Code:

http://redirectmymobiletraffichere.com

Brujah 03-28-2012 12:04 PM

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.

fris 03-28-2012 12:24 PM

http://detectmobilebrowsers.mobi/

Klen 03-28-2012 12:48 PM

Quote:

Originally Posted by fris (Post 18849952)

That's shitty mobile redirect script which cost 100$ monthly,i wouldn't recommend it.


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