Error 404 instead of redirect 302
Sobiech 77
From: -
From: -
Notice
This topic is archived. New comments cannot be posted and votes cannot be cast.Responses to this topic
1 Re: Error 404 instead of redirect 302
Sobiech
OP
77
From: -
From: -
I will look into it for a future update.
However, search engines are only follow links, so it is unlikely that the pages without the .html extension will indexed at all.
Unfortunately, but Google is starting to tell about "duplicate content" - pages "files/details/file" and "files/categories/category" without html (maybe by link "files/categories" Google try to search for addresses without ".html").
-----------------
I try this code:
$query = $database -> dbquery( "SELECT file_id FROM " . DB_PREFIX . "esselbach_ct_files WHERE file_seo = '" . $page_query . "'" );
if( !$database -> dbrows( $query ) )
{
header( "HTTP/1.0 404 Not Found" );
echo "<html><head>\n<title>404 Not Found</title>\n</head><body>\n<h1>Not Found</h1>\n<p>The requested URL " . $_SERVER[ 'REQUEST_URI' ] . " was not found on this server.</p></body></html>";
exit;
}
In filesget.html after "list( $page_query, $opt ) = $system -> getpages( $page, 0 );" and in this place it works good (server returns 404 error for "files/get/deleted_file,1.html") .
1 Re: Error 404 instead of redirect 302
Philipp
From: Austria
Administrator
1342From: Austria
The following should work. Open files/filesdetails.php in an editor and find (near the top):
Then add the following code:
global $config, $database, $templates, $system, $security, $preferences, $user, $ipaddr, $uwrapper;
list( $page_query, $opt ) = $system -> getpages( $page, 0 );
Then add the following code:
$query = $database -> dbquery( "SELECT file_id FROM " . DB_PREFIX . "esselbach_ct_files WHERE file_seo = '" . $page_query . "'" );
if( !$database -> dbrows( $query ) )
{
header( "HTTP/1.0 404 Not Found" );
echo "<html><head>\n<title>404 Not Found</title>\n</head><body>\n<h1>Not Found</h1>\n<p>The requested URL " . $_SERVER[ 'REQUEST_URI' ] . " was not found on this server.</p></body></html>";
exit;
}
1 Re: Error 404 instead of redirect 302
Sobiech
OP
77
From: -
From: -
Is it possible to return errors for files that have been deleted from the database or never been found in the database (#2)?
For example #2:
Link to file: www.example.com/files/details/filename.html
Some (spam) search engines only display part of the link, for example:
www.example.com/files/details/filen...
Google sees the link and it indexes it ...
For example #2:
Link to file: www.example.com/files/details/filename.html
Some (spam) search engines only display part of the link, for example:
www.example.com/files/details/filen...
Google sees the link and it indexes it ...
1 Re: Error 404 instead of redirect 302
Philipp
From: Austria
Administrator
1342From: Austria
I will look into it for a future update.
However, search engines are only follow links, so it is unlikely that the pages without the .html extension will indexed at all.
However, search engines are only follow links, so it is unlikely that the pages without the .html extension will indexed at all.
1 Re: Error 404 instead of redirect 302
Sobiech
OP
77
From: -
From: -
Is it possible to prevent the "duplicate content" and indexing pages with the extension .html and without .html?
Unfortunately, but the links work both with and without an extension, and search engines can index them and treat as "duplicate content"
www.example.com/files/categories/categoryname.html
and
www.example.com/files/categories/categoryname
www.example.com/files/details/filename.html
and
www.example.com/files/details/filename
Unfortunately, but the links work both with and without an extension, and search engines can index them and treat as "duplicate content"
www.example.com/files/categories/categoryname.html
and
www.example.com/files/categories/categoryname
www.example.com/files/details/filename.html
and
www.example.com/files/details/filename
1 Re: Error 404 instead of redirect 302
Philipp
From: Austria
Administrator
1342From: Austria
Done. I just added it to the 2.1.19 code base, which should be out later this week.
Is it possible to set 404 errors for inactive links? Now, when you enter the link www.example.com/somethingold.html or www.example.com/veryold/somethingold.html, it takes a 302 redirect to homepage, even if the content somethingold.html is long inactive... Error 404 will help to remove old and unnecessary content from the search engines.
Regards
Michal