Mobile Redirect PHP Help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • PornHustler
    Confirmed User
    • May 2009
    • 456

    #1

    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
    Contact ICQ: 570768377
    Sub 1:440 Blog Converting Sponsor
  • edgeprod
    Permanently Gone
    • Mar 2004
    • 10019

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

    Comment

    • edgeprod
      Permanently Gone
      • Mar 2004
      • 10019

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

      Comment

      • u-Bob
        there's no $$$ in porn
        • Jul 2005
        • 33063

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

        Comment

        • PornHustler
          Confirmed User
          • May 2009
          • 456

          #5
          Originally posted by u-Bob
          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.
          Contact ICQ: 570768377
          Sub 1:440 Blog Converting Sponsor

          Comment

          • PornHustler
            Confirmed User
            • May 2009
            • 456

            #6
            Originally posted by edgeprod
            You mean include('file'); not include 'file' right?
            It was the path to the php file in a folder on one of my domains.

            Originally posted by edgeprod
            Oh, and you are including the FILE PATH, not some http:// path, right?
            I wasn't but I can do that.
            Contact ICQ: 570768377
            Sub 1:440 Blog Converting Sponsor

            Comment

            • Jakez
              Confirmed User
              • Jan 2004
              • 5656

              #7
              Originally posted by PornHustler
              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?
              [email protected] - jakezdumb - 573689400

              Killuminati

              Comment

              • PornHustler
                Confirmed User
                • May 2009
                • 456

                #8
                Originally posted by Jakez
                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.
                Contact ICQ: 570768377
                Sub 1:440 Blog Converting Sponsor

                Comment

                • PornHustler
                  Confirmed User
                  • May 2009
                  • 456

                  #9
                  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.
                  Contact ICQ: 570768377
                  Sub 1:440 Blog Converting Sponsor

                  Comment

                  • edgeprod
                    Permanently Gone
                    • Mar 2004
                    • 10019

                    #10
                    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)

                    Comment

                    • PornHustler
                      Confirmed User
                      • May 2009
                      • 456

                      #11
                      Originally posted by edgeprod
                      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?
                      Contact ICQ: 570768377
                      Sub 1:440 Blog Converting Sponsor

                      Comment

                      • edgeprod
                        Permanently Gone
                        • Mar 2004
                        • 10019

                        #12
                        Originally posted by PornHustler
                        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.

                        Comment

                        • PornHustler
                          Confirmed User
                          • May 2009
                          • 456

                          #13
                          Originally posted by edgeprod
                          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.
                          Contact ICQ: 570768377
                          Sub 1:440 Blog Converting Sponsor

                          Comment

                          • edgeprod
                            Permanently Gone
                            • Mar 2004
                            • 10019

                            #14
                            Originally posted by PornHustler
                            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.

                            Comment

                            • Jakez
                              Confirmed User
                              • Jan 2004
                              • 5656

                              #15
                              Originally posted by PornHustler
                              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..
                              [email protected] - jakezdumb - 573689400

                              Killuminati

                              Comment

                              • Brujah
                                Beer Money Baron
                                • Jan 2001
                                • 22157

                                #16
                                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

                                Comment

                                • Brujah
                                  Beer Money Baron
                                  • Jan 2001
                                  • 22157

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

                                  Comment

                                  • fris
                                    Too lazy to set a custom title
                                    • Aug 2002
                                    • 55679

                                    #18
                                    http://detectmobilebrowsers.mobi/
                                    Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.

                                    Comment

                                    • Klen
                                      • Aug 2006
                                      • 32235

                                      #19
                                      Originally posted by fris
                                      That's shitty mobile redirect script which cost 100$ monthly,i wouldn't recommend it.

                                      Comment

                                      Working...