Hi all,
I’m trying to minimize some Crawl Errors and Duplicate Content issues in Google Webmaster Tools for article detail pages on my client’s site.
What I’m trying to do is tell Google to only go to and index this url structure for the articles site_url/weblog_url/details_template/url_title/entry_id
I’ve enabled PHP for the details template and included this at the top:
{if segment_4==""}
{exp:weblog:entries weblog="weblog" disable="categories|member_data|pagination|trackbacks" dynamic="on" limit="1" show_future_entries="yes"}
<?
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: /{segment_1}/{segment_2}/{segment_3}/{entry_id}/" );
die();
?>
{/exp:weblog:entries}
{/if}
{if segment_5!=""}
<?
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: /{segment_1}/{segment_2}/{segment_3}/{segment_4}" );
die();
?>
{/if}First one tells Google if no entry_id exist, insert it and redirect with the 301. Second one just tells it to get rid of any 5th url_segments and do the same. That one is really optional but I like it in there. This all works.
If I try to add something like this for incorrect entry_id:
{if "{entry_id}" != "{segment_4}" AND "{url_title}" == "{segment_3}"}
{exp:weblog:entries weblog="weblog" disable="categories|member_data|pagination|trackbacks" dynamic="on" limit="1" show_future_entries="yes"}
<?
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: /{segment_1}/{segment_2}/{segment_3}/{entry_id}/" );
die();
?>
{/exp:weblog:entries}
{/if}It throws the browser for a loop and I get this error message:
The page isn’t redirecting properly
Firefox has detected that the server is redirecting the request for this address in a way that will never complete.
Is this possible?
FYI, I’m using a simplified template for testing with no header embeds.
-Martin