Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm having a problem with my Wordpress install. All of a sudden some of my posts return 404 errors when I try to go to their permalink. My post names are all numbers and this started happening when my numbered posts went over 1000.

So for example, this post works correctly: http://kidlolly.com/post/999/

But this one returns a 404: http://kidlolly.com/post/1000/

Any clue what might be the root of the problem? I am suspect maybe my .htaccess file but I admit I am not super savvy on .htaccess so I'm not quite sure what to look for. I am running a few "security" plugins that affect the .htaccess but since it isn't a problem for posts 1-999 I am not sure what to look for.

Here's where I think the problem might be in .htaccess file (if that is indeed the case), anyone able to help me interpret it?

    RewriteCond %{QUERY_STRING} \.\.\/ [NC,OR]
    RewriteCond %{QUERY_STRING} ^.*(bash|git|hg|log|svn|swp|cvs) [NC,OR]
    RewriteCond %{QUERY_STRING} etc/passwd [NC,OR]
    RewriteCond %{QUERY_STRING} boot\.ini [NC,OR]
    RewriteCond %{QUERY_STRING} ftp\:  [NC,OR]
    RewriteCond %{QUERY_STRING} http\:  [NC,OR]
    RewriteCond %{QUERY_STRING} https\:  [NC,OR]
    RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
    RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|%3D) [NC,OR]
    RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [NC,OR]
    RewriteCond %{QUERY_STRING} ^.*(\[|\]|\(|\)|<|>|ê|"|;|\?|\*|=$).* [NC,OR]
    RewriteCond %{QUERY_STRING} ^.*(&#x22;|&#x27;|&#x3C;|&#x3E;|&#x5C;|&#x7B;|&#x7C;).* [NC,OR]
    RewriteCond %{QUERY_STRING} ^.*(%24&x).* [NC,OR]
    RewriteCond %{QUERY_STRING} ^.*(%0|%A|%B|%C|%D|%E|%F|127\.0).* [NC,OR]
    RewriteCond %{QUERY_STRING} ^.*(globals|encode|localhost|loopback).* [NC,OR]
    RewriteCond %{QUERY_STRING} ^.*(request|select|concat|insert|union|declare).* [NC]
    RewriteCond %{QUERY_STRING} !^loggedout=true
    RewriteCond %{QUERY_STRING} !^action=rp
    RewriteCond %{HTTP_COOKIE} !^.*wordpress_logged_in_.*$
    RewriteCond %{HTTP_REFERER} !^http://maps\.googleapis\.com(.*)$
    RewriteRule ^(.*)$ - [F,L]

Thanks in advance!

share|improve this question
1  
how are these permalinks generated? they appear to be sequential and not based on post ID. –  Milo Jan 23 '13 at 17:40
    
They are the title of the post. I title each post in sequential order so the actual page title is "1000" or "999" etc. (It's manual not automated) –  Zara Jan 23 '13 at 17:48
    
well, I've figured out what's happening, though I'm not sure at the moment how to fix it. Your post permalink matches the year archive rewrite rule because it's a 4 digit number, so WordPress is trying to load an archive for the year 1000, which doesn't exist. –  Milo Jan 23 '13 at 18:32

1 Answer 1

up vote 2 down vote accepted

As I mentioned in my comment, the date rewrite rule is picking up your post permalink and trying to load a year archive instead of your single post. Since it appears you don't use date URLs on your site, you can change the date structure so it no longer clashes. Add this to your theme's functions.php file, then visit the Settings > Permalinks page in Admin to flush the rewrite rules:

function wpa82820_date_structure(){
    global $wp_rewrite;
    $wp_rewrite->date_structure = 'date/%year%/%monthnum%/%day%';
}
add_action( 'init', 'wpa82820_date_structure' );

This changes date URLs from /2013/01/23/ to /date/2013/01/23/ so they no longer clash with 4 digit single post permalinks.

share|improve this answer
    
That worked perfectly. Thank you so much for your help! I would never have been able to figure that out on my own. –  Zara Jan 23 '13 at 21:23

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.