Jump to content

Recommended Posts

Hi All,

 

Not sure if this is the right forum or not, so here goes!

 

Just trying to generate a sitemap using: http://www.sitemapdoc.com/Default.aspx but get the error:

too many automatic redirections were attempted.

 

 

I've a 301.php redirect file on my site to handle redirects and contains:

if (isset($map[$_SERVER['REDIRECT_URL']])) {
    $new_loc = 'http://' .
               $_SERVER['HTTP_HOST'] .
               $map[$_SERVER['REDIRECT_URL']];
    if (isset($_SERVER['REDIRECT_QUERY_STRING'])) {
        $new_loc .= '?' .
                    $_SERVER['REDIRECT_QUERY_STRING'];
    }
    header("HTTP/1.1 301 Moved Permanently");
    header("Location: $new_loc");
} else {
    header("HTTP/1.1 301 Moved Permanently");
    header("Location: ".$_SERVER['HTTP_HOST']);
}

 

Is it an issue with my 301 causing the above error or something else?

 

Many thanks

You are displaying a 301 header and then redirecting. Essentially you are using 2 301 redirects as the header() will use a 301 also.

Use this tool to see what is happening.

http://www.internetofficer.com/seo-tool/redirect-check/

Are you trying to redirect old urls to new urls?

If so, you shouldn't really use code to handle this. You should use your .htaccess file to define your 404 document and any 301 redirects. It seems to me that you are redirecting to the script containing the code above which is then redirecting again. Too many redirects! Google may see this as malicious.

If you put the problematic urls in the tool that i gave the link for it will tell you what is happening.

Hi neil.johnson

 

Yes, I'm redirecting old URLS to new ones. As there were so many, I opted for a 301.php file which listed the files old -> new.

This also allowed me to display a page not found option. As the site admin configured the server to use this as the 404. Therefore, it in essessence should redirect or show the error I believe.

 

using the tool it shows:

Checked link: http://www.domain.com/tes.htm

 

Type of redirect: 301 Moved Permanently

 

Redirected to: http://www.domain.com/index.htm

 

So it looks right!? Rather than using the .htaccess file, is there a simple way to alter my PHP code not to handle the double redirect?

 

Thanks

Failing that, how do I alter my .htaccess file? It currently has:

# -FrontPage-

 

IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*

ErrorDocument 404 /301.php

<Limit GET POST>

order deny,allow

deny from all

allow from all

</Limit>

<Limit PUT DELETE>

order deny,allow

deny from all

</Limit>

 

Thanks

Should I remove the stuff in my 301.php file apart from the error, then add this to my htaccess:

redirect 301 /test.htm http://www.domain.com/index.htm

Repeating that for each entry I need.

If so, shall I add it below:

ErrorDocument 404 /301.php

Or does it need to go at the end of the htaccess file, i.e. after </Limit>

 

Thanks

This is the problem

ErrorDocument 404 /301.php

You are throwing a 404 to 301.php which is then throwing a 301 to a 200.

 

This is the simplest form for your .htaccess

# 404 page
ErrorDocument 404 /missing.html
# 301 redirects
Redirect 301 http://www.foobar.com/old.html http://www.foobar.com/new.html

Create a general 404 page. I have called it missing.html. On that page you could have a link back to your homepage that the user can click on. Similar to the following: http://www.bbc.co.uk/yhguyg.html

 

Do not use the 301.php file at all

 

Read the following

http://www.isitebuild.com/301-redirect.htm

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.