Page 1 of 1

404 when selecting category view

Posted: Wed Nov 24, 2010 12:28 am
by Don Chambers
I have a few sites under development, that unfortunately cannot be shown here. s9y 1.5.4 and PHP 5.3.3. The site is a virtual private server provided by Verio.

I am having a random 404 error when showing category views, ie http://mysite.com/categories/category-name.

This is the first time I have ever configured a site to NOT use an ID number in the permalink configuration (categories/%id%-%name%). Instead, I am using categories/%name%. I do not know why it would matter, but this is the only time I have ever used that.

The site using Apache mod rewrite for URL rewriting. I have not modified s9y's default .htaccess for url rewriting:

Code: Select all

# BEGIN s9y
ErrorDocument 404 /index.php
DirectoryIndex /index.php

RewriteEngine On
RewriteBase /
RewriteRule ^serendipity_admin.php serendipity_admin.php [NC,L,QSA]
RewriteRule ^((archives/([0-9]+)\-[0-9a-z\.\_!;,\+\-\%]+\.html)/?) index.php?/$1 [NC,L,QSA]
RewriteRule ^(authors/([0-9]+)\-[0-9a-z\.\_!;,\+\-\%]+) index.php?/$1 [NC,L,QSA]
RewriteRule ^(feeds/categories/([0-9;]+)\-[0-9a-z\.\_!;,\+\-\%]+\.rss) index.php?/$1 [NC,L,QSA]
RewriteRule ^(feeds/authors/([0-9]+)\-[0-9a-z\.\_!;,\+\-\%]+\.rss) index.php?/$1 [NC,L,QSA]
RewriteRule ^(categories/([0-9;]+)\-[0-9a-z\.\_!;,\+\-\%]+) index.php?/$1 [NC,L,QSA]
RewriteRule ^archives([/A-Za-z0-9]+)\.html index.php?url=/archives/$1.html [NC,L,QSA]
RewriteRule ^([0-9]+)[_\-][0-9a-z_\-]*\.html index.php?url=$1-article.html [L,NC,QSA]
RewriteRule ^feeds/(.*) index.php?url=/feeds/$1 [L,QSA]
RewriteRule ^unsubscribe/(.*)/([0-9]+) index.php?url=/unsubscribe/$1/$2 [L,QSA]
RewriteRule ^approve/(.*)/(.*)/([0-9]+) index.php?url=approve/$1/$2/$3 [L,QSA]
RewriteRule ^delete/(.*)/(.*)/([0-9]+) index.php?url=delete/$1/$2/$3 [L,QSA]
RewriteRule ^(admin|entries)(/.+)? index.php?url=admin/ [L,QSA]
RewriteRule ^archive/? index.php?url=/archive [L,QSA]
RewriteRule ^(index|atom[0-9]*|rss|b2rss|b2rdf).(rss|rdf|rss2|xml) rss.php?file=$1&ext=$2
RewriteRule ^(plugin|plugin)/(.*) index.php?url=$1/$2 [L,QSA]
RewriteRule ^search/(.*) index.php?url=/search/$1 [L,QSA]
RewriteRule ^comments/(.*) index.php?url=/comments/$1 [L,QSA]
RewriteRule ^(serendipity\.css|serendipity_admin\.css)$ index.php?url=/$1 [L,QSA]
RewriteRule ^index\.(html?|php.+) index.php?url=index.html [L,QSA]
RewriteRule ^htmlarea/(.*) htmlarea/$1 [L,QSA]
#RewriteCond %{REQUEST_URI} !-U
RewriteRule (.*\.html?) index.php?url=/$1 [L,QSA]

<Files *.tpl.php>
    deny from all
</Files>

<Files *.tpl>
    deny from all
</Files>

<Files *.sql>
    deny from all
</Files>

<Files *.inc.php>
    deny from all
</Files>

<Files *.db>
    deny from all
</Files>

# END s9y
I can temporarily solve the problem by going to s9y's configuration, setting the url rewriting to disabled, then re-enabling it as apached mod rewrite. This completely solves the problem, and I stop getting the 404 page not found error. When I do a diff of the two htaccess files, they are absolutely identical!!!!! I know the config file gets rewritten too, and a diff of those shows they are identical.

The error will get corrected, then reappear several days later. I cannot find any correlation between what I am doing on the site (entries, etc) and the beginning of this error. I do not see any errors in the error log. Any ideas?

EDIT: I should point out that I am not getting an apache 404, I am getting the condition of my template for {if view =='404'}...

Re: 404 when selecting category view

Posted: Wed Nov 24, 2010 10:23 pm
by garvinhicking
Hi!

Your rewriterules still containt /categories/XX-xxx - that shouldnt happen. When you changed the permalink patterns, was your .htaccess file writable for s9y? Seems it couldnt write to the file to adjust the rewriterules to the change in your permalink pattern.

Try to change something in the patterns and see if htaccess properly gets updated, also check permissions.

Must be somehow related to the .htaccess getting reset...

Regards,
Garvin

Re: 404 when selecting category view

Posted: Thu Nov 25, 2010 12:41 am
by Don Chambers
Thanks Garvin. Rewriting the .htaccess file, (or, more accurately, changing and saving the s9y configuration which does rewrite the htaccess file) solved the problem, there was absolutely no difference in the htaccess file content, nor permissions before, or after being rewritten.

Re: 404 when selecting category view

Posted: Thu Nov 25, 2010 10:42 am
by garvinhicking
Hi!

You might want to check your serendipity_permalinks table then, if that one changes contents from where it works vs. where it doesn't?

Regards,
Garvin

Re: 404 when selecting category view

Posted: Thu Nov 25, 2010 4:14 pm
by Don Chambers
One more piece of info - it is never ALL category views that don't work, it is only some... and it appears random. Sometimes category 1 might not work, another time it might be category 4, 5 & 6. It is very strange.