Announcement

Collapse
No announcement yet.

htaccess permanent redirection help

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

    htaccess permanent redirection help

    I would like some help with an htaccess file permanent redirect. I can't seem to get it to work as I need.

    I need to permanently redirect all pages in www.myoldsite.fr/en to www.mynewsite.com without affecting any other files in www.myoldsite.fr.

    There are normal Sellerdeck files etc in both www.myoldsite.fr and www.myoldsite.fr/en but the ones in the root need to remain as is - only those in the subdirectory of en need to be redirected off to the new domain.

    The hosting is with 1and1 if it makes any difference.

    Any help appreciated.

    #2
    I always find these things to be a bit of a pain and require a degree of trial and error

    assuming you can use a .htaccess file, put it in the /en/ folder

    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^www.myoldsite.fr$
    RewriteRule ^(.*)$ http://www.mynewsite.com/$1 [R=301]

    If that doesn't work give me a shout and I'll do a little testing trial and error
    Steve Wardell
    Operations Director
    __________________________

    Comment


      #3
      Does something like this work:
      Code:
      RewriteEngine On
      RewriteBase /
      RewriteRule ^en(.*)$ http://www.mynewsite.com/$1 [L,R=301]
      You may have store and cgi-bin folders inside "en" folder you'd have to test for, you could add additional rewrite rules.
      Peblaco

      Comment


        #4
        The first method was what I had tried and doesn't seem to work. The second does work (when placed in the root of myoldsite.fr but results in a destination URL of for example http://www.mynewsite.com//acatalog/xxx.html. It does work (in FF, IE and Chrome) but I would like ot get rid of the additional forward slash if possible.

        I'm also not sure how to set up the additional rules for the cgi-bin redirection, acatalog works with the rules as is as does the homepage.

        Comment


          #5
          I'm also not sure how to set up the additional rules for the cgi-bin redirection, acatalog works with the rules as is as does the homepage.
          Hi Duncan,

          Can you expand on the need for cgi-bin redirection. If everyone has already been sent to the new domain then there should be no need to redirect any cgi-bin requests.

          Unless there's an existing cookie holding the old locations but this should expire fairly quickly. (this is probably complete tosh as the old cookie shouldn't be visible on the new domain - so again I don't understand why you need to redirect any cgi-bin requests).

          Mike
          -----------------------------------------

          First Tackle - Fly Fishing and Game Angling

          -----------------------------------------

          Comment


            #6
            Hi Mike,

            For example, this page redirects:
            www.myoldsite.fr/en/acatalog/xxx.html‎
            but this page doesn't:
            http://www.myoldsite.fr/en/cgi-bin/s...l?ACTION=LOGIN
            Maybe it's cookies, although I did try clearing the cache and other browsers.

            Comment


              #7
              OK. So it's for people who have bookmarked the login page. I was thinking that everyone would end up on the right domain before trying to access the cgi-bin so there shouldn't be a problem.

              Can you see what the redirect does for you currently with the cgi-page? I can't see it because BT in their stupidity present a bloody yahoo search page instead of the 404 error.

              Mike
              -----------------------------------------

              First Tackle - Fly Fishing and Game Angling

              -----------------------------------------

              Comment


                #8
                It gives a 404.
                I also notice in (FF only) that the redirection that works for the acatalog page produces a double slash after the domain name ie like this:
                http://www.mynewsite.com//acatalog/xxx.html

                Comment


                  #9
                  Can you post the actual urls as seeing the result of the redirect is part of working out what's going wrong.

                  Mike
                  -----------------------------------------

                  First Tackle - Fly Fishing and Game Angling

                  -----------------------------------------

                  Comment


                    #10
                    PS. To avoid the double slash problem, remove the / before $1 in this

                    RewriteRule ^(.*)$ http://www.mynewsite.com/$1 [R=301]
                    it isn't needed.

                    Mike
                    -----------------------------------------

                    First Tackle - Fly Fishing and Game Angling

                    -----------------------------------------

                    Comment


                      #11
                      Removing the slash has removed the double slash - thank.

                      Here are the actual URLs (Just remove THIS)

                      These links redirect ok:
                      www.phytoforceTHIS.fr/en
                      http://www.phytoforceTHIS.fr/en/acat...ce.html‎

                      These links don't redirect:
                      http://www.phytoforceTHIS.fr/en/cgi-...CTION=SHOWCART
                      http://www.phytoforceTHIS.fr/en/cgi-...l?ACTION=LOGIN

                      Note that the structure in the root is:
                      www.phytoforceTHIS.fr - to stay as is
                      www.phytoforceTHIS.fr/acatalog - to stay as is
                      www.phytoforceTHIS.fr/cgi-bin - to stay as is
                      www.phytoforceTHIS.fr/eu - to stay as is
                      www.phytoforceTHIS.fr/eu/acatalog - to stay as is
                      www.phytoforceTHIS.fr/eu/cgi-bin - to stay as is
                      www.phytoforceTHIS.fr/en - to be redirected to www.phytoforce-tonicsTHIS.com
                      www.phytoforceTHIS.fr/en/acatalog - to be redirected to www.phytoforce-tonicsTHIS.com/acatalog
                      www.phytoforceTHIS.fr/eu/cgi-bin - to be redirected to www.phytoforce-tonicsTHIS.com/cgi-bin

                      Comment


                        #12
                        The problem with the Perl redirects might be the query strings see here and here.
                        Peblaco

                        Comment


                          #13
                          Thanks for the links Louise - I'll take a look at the Query Strings.

                          The more I think about it the more I'm convincing myself that the cgi links aren't really important to redirect. They might be best just to die a death as 404s. The important pages are working fine. The one exception might be the login page but that would be quite rare anyway. Life's too short and it's Friday after all.

                          Comment


                            #14
                            It looks like there's something else interfering with this. What you have redirects everything else, even something like /oddfile/doesnt/exist/ but as soon as /cgi-bin/ is used the redirect doesn't do anything. (even without any query strings).

                            I'd check there's nothing you can see in any other htaccess files that could be causing this and then get onto 1and1 support. It must be something they're doing at their end.

                            Mike
                            -----------------------------------------

                            First Tackle - Fly Fishing and Game Angling

                            -----------------------------------------

                            Comment


                              #15
                              assuming you have a custom 404 that directs people to your home page letting the CGI links die should be fine IWHT
                              Steve Wardell
                              Operations Director
                              __________________________

                              Comment

                              Working...
                              X