Forum Moderators: phranque

Message Too Old, No Replies

Server returns 404 response header

404 error problem with website that is still showing

         

zsigmondre

6:18 pm on Jun 26, 2008 (gmt 0)

10+ Year Member



Hi everybody,

I have a big problem <snip>. When I access the site the main page is shown correctly, but I recently found out that it returns a 404 error in the server response header.
The whole site is working but all the pages return a 404 error and don't know why. The site is run by cubecart 3.0.13 and is hosted on a unix server with apache 2.2.8.

I would appreciate if you could help me solve this very annoying problem.

Thanks in advance,
zsigmondre

[edited by: jdMorgan at 6:51 pm (utc) on June 26, 2008]
[edit reason] No URLs, please. See Terms of Service. [/edit]

jdMorgan

10:35 pm on Jun 26, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is there an .htaccess file in the root directory or in the cart directory? If so, we'll need to see it.

Jim

zsigmondre

5:57 am on Jun 27, 2008 (gmt 0)

10+ Year Member



Thank you for your quick answer Jim.
There is a .htaccess file int the root and it looks like this:

<FilesMatch .asp>
SetHandler application/x-httpd-php5
</FilesMatch>
DirectoryIndex index.asp index.php index.htm index.html

redirect 301 /wordpress http://www.example.com/blog

redirect 301 /index.php http://www.example.com/store/

And the one in the store directory is this:

RewriteEngine On

RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/store/$1 [R=301,L]

RewriteCond %{QUERY_STRING} (.+)
RewriteRule cat_(.*).html index.php?act=viewCat&catId=$1&%1 [L]
RewriteRule cat_(.*).html index.php?act=viewCat&catId=$1 [L]
RewriteCond %{QUERY_STRING} (.+)
RewriteRule prod_(.*).html index.php?act=viewProd&productId=$1&%1 [L]
RewriteRule prod_(.*).html index.php?act=viewProd&productId=$1 [L]
RewriteCond %{QUERY_STRING} (.+)
RewriteRule info_(.*).html index.php?act=viewDoc&docId=$1&%1 [L]
RewriteRule info_(.*).html index.php?act=viewDoc&docId=$1 [L]
RewriteCond %{QUERY_STRING} (.+)
RewriteRule site_(.*).html index.php?act=viewDoc2&docId2=$1&%1 [L]
RewriteRule site_(.*).html index.php?act=viewDoc2&docId2=$1 [L]
RewriteCond %{QUERY_STRING} (.+)
RewriteRule tell_(.*).html index.php?act=taf&productId=$1&%1 [L]
RewriteRule tell_(.*).html index.php?act=taf&productId=$1 [L]

I'm not sure what the problem is but it's causing me a lot of headache.

[edited by: jdMorgan at 4:26 pm (utc) on June 28, 2008]
[edit reason] Use example.com. See TOS. [/edit]

jdMorgan

4:29 pm on Jun 28, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Nothing there -- The code is inefficient, but it won't invoke a 404.

Do you get 404s on /wordpress requests, on /index.php requests, on /cat_, /prod_, /info_, /site_, /tell_ requests, or on *all* requests?

[added] Please use example.com instead of your own domain. Otherwise, this thread may out-rank your own site by tomorrow for a search on your domain name. I'm not sure you'd want your competitors to know about your trouble, either... [/added]

Jim

[edited by: jdMorgan at 4:32 pm (utc) on June 28, 2008]

zsigmondre

9:00 pm on Jun 28, 2008 (gmt 0)

10+ Year Member



Thank you Jim for making the necessary changes in my post. The only reason I included the domain is that I thought if you have a look at the site then maybe it's easier to see what's causing the error.
As I know right now all the cubecart pages return a 404 error where the url has been rewritten, but not the wordpress or the static pages, so the problem should be there but I couldn't find it until now.
Hope that I'll fix this problem soon cause it really hurts the site.

zsigmondre

jdMorgan

9:53 pm on Jun 28, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



An old kludge to support dynamic pages (but with horrible side-effects) was to define the script that generated those pages as the custom 404 Error Document for a directory. Since dynamic URLs do not exist as actual/real/physical files on the server, any request for a dynamic page would generate a 404. The script would then be invoked, since it was the error page for 404 errors, and would generate content for that page's URL.

This purpose of this kludge was for use on Web hosts that did not support mod_rewrite, as it was the only way to pass control to a script without using a redirect. It was popular on GeoCities, for example. But this was well before the Web went commercial and search engine ranking became important. Since browsers didn't really care about getting a 404 and displayed the resulting pages just fine, it worked well enough in its time.

It is possible that your cart still uses this method, or that it uses it unless told to use mod_rewrite. I don't know anything about cubecart, but you might want to check out their documentation and/or forums to see if there is any mention of this.

If you can configure it to use mod_rewrite as a built-in option, then do so. If not, then look at any .htaccess file in cubecart's subdirectory, and see if there is an ErrorDocument directive pointing 404's to the script. If so, it can likely be replaced with a mod_rewrite ruleset, avoiding this 404 problem.

Jim

g1smd

7:44 pm on Jun 29, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I still see people using that kludge from time to time.

It complicates, not simplifies, the issues.

zsigmondre

1:56 pm on Jul 1, 2008 (gmt 0)

10+ Year Member



Thanks for the clues, unfortunately it isn't the situation because the seo mod uses Apache RewriteRule for generating the urls and I cannot find in any .htaccess file the ErrorDocument directive. So if the rewriterule works because the seo urls are displayed and the right content is displayed as well then I don't know where the 404 error is generated.

zsigmondre

zsigmondre

2:57 pm on Jul 1, 2008 (gmt 0)

10+ Year Member



I was just thinking is there any way to set the header response to 200 for every page? Could this be a temporary solution until I can somehow find the source of this problem?

Thanks,
zsigmondre

jdMorgan

3:26 pm on Jul 1, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You might be able to modify your scripts to always return a 200-OK, but I'm not aware of any other way to do it.

If there is no ErrorDocument directive pointing to a page-generation script, then it's fairly likely that the script itself is generating the 404s.

Sorry I can't be of more help -- this is a nasty problem... :(

Jim

zsigmondre

3:42 pm on Jul 1, 2008 (gmt 0)

10+ Year Member



Thank you Jim for your time and hopefully I will find out soon whats causing the error.

Best regards,
zsigmondre