Announcement

Collapse
No announcement yet.

php pages

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    php pages

    Can anyone tell me if it's possible to create a php redirect page on some spare hosting with a specific qualifier. I know nothing of php.

    Basically I was assisting somebody with a move from Express to Business and we and Actinic have failed to get any meaningful redirect from the Express site which is still fully indexed and has decent page rank and SERPs on about 36 pages which were top sellers and have now slowed to a halt. We need 301's to the new pages.

    The Express pages look like

    ww.website-shop.codotuk/index.php?page_name_or_something

    and we have come down to the only option being to move the domain to our own hosting and solve it there.

    The question is, can we recreate this exact URL on our own hosting and use a proper php redirect on that page which I believe might look something like

    <?
    Header( "HTTP/1.1 301 Moved Permanently" );
    Header( "Location: http://www.website.co.uk/shop/page-name-or-something.html" );
    ?>

    Anyone know how we can achieve this?
    Blank DVD
    Cloth Nappies

    #2
    Something like

    PHP Code:
    <?php
    $sURL 
    'http://www.website.co.uk';
    $sPage = isset($_GET['cat']) ? trim($_GET['cat']) : '';
    if (!empty(
    $sPage) && ((stripos($sPage"http://") == false) && (stripos($sPage"https://") == false)))
        { 
        
    $sURL .= '/shop/' $sPage '.html';
        }

    header('Status: 301');
    header('Location: ' $sURL);
    exit();
    ?>
    Should do the trick, if the page name isnt set then it will redirect to the main website, or if people try and inject redirects to other websites it will just redirect to the homepage.

    This does make the assumption that the pages on the new site match the category names from Express. It also makes the assumption that your server is running PHP5.

    Comment


      #3
      Hi Mark,

      Forgive my ignorance. The business I am assisting had a frontpage site with content which linked to an Actinic Express site for the cart.

      So the main pages looked like mainsite.co.uk/info.html

      This was hosted on their server. The Express site URL's were mainsite-shop.co.uk which is a URL the company own. This was hosted on Actinics Express servers and the back end generated URLs such as mainsite-shop.co.uk/index.php?product_name

      Now, many of these URL's are indexed by google and have good ranking. The business has now moved to the full Actinic Business package and uploaded the site to

      mainsite.co.uk/shop/.....

      Actinic have been unable to get working 301's on their hosting to direct mainsite-shop/index.php?product_name over to mainsite.co.uk/shop/product-name.html

      I think this is a big black hole in the upgrade service and needs to be fixed.

      The one option we have is to get the mainsite-shop.co.uk domain onto some seperate hosting where we actually have access to it and recreate pages such as mainsite-shop.co.uk/index.php?product_name and on that page put in a proper 301 redirect to the relevent html page on the new Actinic Business site.

      What I need to know is if it will be possible to create URL's with this exact URL and if we can then add 301's to those page to redirect to the new page?

      I may well be barking up the wrong tree here as I guess the stuff after the ? is server side but I really don't quite understand it enough to figure it out. I've spent enough on spanners who are supposed to be web gurus in 2008 to recommend this course of action to them. By the same token, I don't have the time to sit and plough through unless I know this will be possible.

      I hope you get what I am talking about.
      Blank DVD
      Cloth Nappies

      Comment


        #4
        Originally posted by Stereo Steve View Post
        What I need to know is if it will be possible to create URL's with this exact URL and if we can then add 301's to those page to redirect to the new page?
        Using the code above all you need to do is setup some basic hosting with just PHP5 and point the existing store domain at the hosting then upload the code as a file called index.php

        It will then intercept all the express URL's and will send a 301 redirect to the new domain.

        The express URLs are built using

        http://mainsite-shop.co.uk/index.php?cat=pagename

        The code above will intercept the above URL and will then send a 301 redirect to

        http://mainsite.co.uk/shop/pagename.html

        Which from your original posting is what you are trying to achieve?

        Comment


          #5
          btw, you can also do the same without using PHP at all.

          If your server supports mod_rewrite then point the existing actinic express store domain to it and then add the following as .htaccess

          RewriteEngine On

          RewriteCond %{QUERY_STRING} cat=([-a-zA-Z0-9_+]+)
          RewriteRule ^/?index\.php$ http://mainsite.co.uk/shop/%1.html? [R=301,L]

          This will redirect

          http://mainsite-shop.co.uk/index.php?cat=pagename

          To

          http://mainsite.co.uk/shop/pagename.html

          Comment


            #6
            Thanks Mark,

            What if the page name extension bits are different?

            Express did not give the option I don't think but for example

            mainsite-shop.co.uk/index.php?cat=purple_trousers

            needs to be redirected to

            mainsite.co.uk/shop/lovely-purple-slacks.html

            If you get my drift?
            Blank DVD
            Cloth Nappies

            Comment


              #7
              Originally posted by Stereo Steve View Post
              What if the page name extension bits are different?

              Express did not give the option I don't think but for example

              mainsite-shop.co.uk/index.php?cat=purple_trousers

              needs to be redirected to

              mainsite.co.uk/shop/lovely-purple-slacks.html
              If there isn't a direct match between the old and new page names then an automatic redirect is much more difficult.

              Are all the pages renamed?

              The easiest option IMO would be to setup a map between the old express name and the new EC name using PHP.

              For example

              PHP Code:
              <?php
              $arrPages 
              = array(
                 
              'purple_trousers' => 'lovely-purple-slacks',
                 
              'product_name_2' => 'lovely-purple-shirts',
                 
              'product_name_3' => 'lovely-white-shoes',
              );

              $sURL 'http://www.website.co.uk';
              $sPage = isset($_GET['cat']) ? trim($_GET['cat']) : '';
              if (!empty(
              $sPage) && ((stripos($sPage"http://") === false) && (stripos($sPage"https://") === false)))
                  {
                  if (isset(
              $arrPages[$sPage]))
                      {
                      
              $sURL .= '/shop/' $arrPages[$sPage] . '.html';
                      }
                  }

              header("Status: 301");
              header('Location: ' $sURL);
              exit();
              ?>
              This will redirect

              http://mainsite-shop.co.uk/index.php...urple_trousers

              to

              http://mainsite.co.uk/shop/lovely-purple-slacks.html

              and

              http://mainsite-shop.co.uk/index.php?cat=product_name_2

              to

              http://mainsite.co.uk/shop/lovely-purple-shirts.html

              Etc etc using a 301 redirect.

              Again, all thats needed is to setup some hosting that runs PHP5 and upload the code as index.php and it will handle the redirects.

              Comment


                #8
                Thanks for your help Mark, it's much appreciated. I assume the website.co.uk in your code is the URL of the new site?

                So, you are saying we just need to create one index page and then put in the code with all the redirects done manually? This could be a great help for them if it works. Thanks very much.
                Blank DVD
                Cloth Nappies

                Comment


                  #9
                  Originally posted by Stereo Steve View Post
                  Thanks for your help Mark, it's much appreciated. I assume the website.co.uk in your code is the URL of the new site?
                  No problem! Yes correct the website.co.uk is the new URL where you want the redirects to go to.

                  Originally posted by Stereo Steve View Post
                  So, you are saying we just need to create one index page and then put in the code with all the redirects done manually? This could be a great help for them if it works. Thanks very much.
                  Correct, upload the PHP above in a file called index.php and then point the express domain at the new hosting space, then all product links will redirect with a 301 to the new store pages.

                  Comment


                    #10
                    Excellent, we'll give it a go.
                    Blank DVD
                    Cloth Nappies

                    Comment


                      #11
                      Mark, a big thanks for this help. We finally got some new hosting sorted and the domain shifted and it has worked a treat.

                      Actinic need to take this on board as a solution to the Express- Catalog upgrade route as the penalty for not having proper 301's can be massive.
                      Blank DVD
                      Cloth Nappies

                      Comment

                      Working...
                      X