• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

Redirect error

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

    Redirect error

    SEO toolkit is showing following error for http://mysite.co.uk/

    The link to "http://mysite.co.uk/" has resulted in a redirection to "http://www.mysite.co.uk/" which resulted in another redirection.

    Not sure where this is coming from. I use a shopping cart with PHP sessions and all PHP pages needs to be in one directory level. My home page is /pages/home.php.

    index.html is:

    <!DOCTYPE HTML>
    <html lang="en-US">
    <head>
    <meta charset="UTF-8">
    <meta http-equiv="refresh" content="1;url="/pages/home.php">
    <script type="text/javascript">
    window.location.href = "/pages/home.php"
    </script>
    <title>Page Redirection</title>
    </head>
    <body>
    <p>If you are not redirected automatically, follow the <a href='/pages/home.php'>link to home page</a></p>
    </body>
    </html>

    index.php is:

    <?php
    header("location:/pages/home.php");
    ?>

    htaccess has:
    RewriteEngine On
    RewriteRule ^index\.html$ / [R=301,L]
    RewriteCond %{HTTP_HOST} ^gatekeeperel.co.uk
    RewriteRule (.*) http://www.gatekeeperel.co.uk/$1 [R=301,L]


    Any ideas where the fault is there? Can't find anything that makes any sense on internet. Ta.
    bloggoth

    If everything isn't black and white, I say, 'Why the hell not?'
    John Wayne (My guru, not to be confused with my beloved prophet Jeremy Clarkson)

    #2
    You've left the actual domain name in the .htaccess code even though you replaced it with mysite.co.uk everywhere else

    Not sure where the "double redirect' thing is coming from. I just had a try with an HTTP debugging proxy running. Going to the domain without www resulted in a single "301 Moved Permanently" to www.mysite.co.uk, as expected from the rewrite rules
    Code:
    RewriteCond %{HTTP_HOST} ^mysite.co.uk
    RewriteRule (.*) http://www.mysite.co.uk/$1 [R=301,L]
    None of the stuff supposedly in index.html or index.php seems to have applied in my case, as there was no further redirect and I got a page showing your products.

    Does it refer to any particular URLs in the report? I tried adding something to the basket, which caused an HTTP POST to guides.php, which redirected back to guides.php via a GET - all perfectly normal. Going to checkout caused an HTTP POST to guides.php which redirected to checkout.php - again, all fine.

    At no point was I sent to /pages/home.php though, so I'm not sure what that bit's about

    Comment


      #3
      Could it be that RewriteRule for index.html in the .htaccess.
      Looks like if it finds you've entered index.html, it just redirects to the root, which on most Web servers is index.html.
      Don't believe it, until you see it!

      Comment


        #4
        Same as Nick - I get redirected to the www version, but then the page displays correctly.

        You haven't got any .htaccess files lurking in subfolders have you?

        Comment


          #5
          Great! Ta for detailed answers. Nice to know most of it works, . Ta for the time spent!

          At no point was I sent to /pages/home.php though
          Wouldn't now. Been simplifying structure. The subdirectory for the main cart pages was originally so I could I could test it all out while still leaving old shopping cart up. Was working on it yesterday and moved all up to root directory, changed home.php to index.php. Made sure got consistent use of / and no http refs to my own stuff.

          This htaccess is a total mystery, so many variations on net. As I now have an index.php in the root directory as far as I can see only redirect I need is to ensure that anyone typing rubbish.co.uk, rubbish.co.uk/index.html, www.rubbish.co.uk/index.php etc etc is shown www.rubbish.co.uk with no specific page names. (Note have a sub domain with index.html and own htaccess, don't want to mess that up). The following sorts the rubbish.co.uk and www.rubbish.co.uk problems:

          DirectoryIndex index.php
          RewriteEngine on
          RewriteCond %{HTTP_HOST} ^example.com [NC]
          RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301,NC]

          However, tried various things and going to index.php from another page on the site still causes index.php to show in the toolbar. What actually works there?
          Last edited by xoggoth; 22 January 2015, 11:01.
          bloggoth

          If everything isn't black and white, I say, 'Why the hell not?'
          John Wayne (My guru, not to be confused with my beloved prophet Jeremy Clarkson)

          Comment


            #6
            This seems to do all I want:

            DirectoryIndex index.php
            #Force www:
            RewriteEngine On
            RewriteRule ^index\.html$ / [R=301,L]
            RewriteCond %{HTTP_HOST} ^gatekeeperel.co.uk [NC]
            RewriteRule ^(.*)$ http://www.gatekeeperel.co.uk/$1 [L,R=301,NC]
            #avoid explicit index.php
            RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
            RewriteCond %{REQUEST_URI} !/system/.* [NC]
            RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]

            HTACCESS seems more complicated than entire programming languages! Gordon Bennet!
            bloggoth

            If everything isn't black and white, I say, 'Why the hell not?'
            John Wayne (My guru, not to be confused with my beloved prophet Jeremy Clarkson)

            Comment


              #7
              Originally posted by xoggoth View Post
              This seems to do all I want:

              DirectoryIndex index.php
              #Force www:
              RewriteEngine On
              RewriteRule ^index\.html$ / [R=301,L]
              RewriteCond %{HTTP_HOST} ^gatekeeperel.co.uk [NC]
              RewriteRule ^(.*)$ http://www.gatekeeperel.co.uk/$1 [L,R=301,NC]
              #avoid explicit index.php
              RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
              RewriteCond %{REQUEST_URI} !/system/.* [NC]
              RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]

              HTACCESS seems more complicated than entire programming languages! Gordon Bennet!
              It sure is

              Comment


                #8
                It sure is
                Agh! Removed "DirectoryIndex index.php" that was giving me a forbidden error on subdomain. All seems ok now. Ta again for help.
                bloggoth

                If everything isn't black and white, I say, 'Why the hell not?'
                John Wayne (My guru, not to be confused with my beloved prophet Jeremy Clarkson)

                Comment

                Working...
                X