Forums

Permalinks problems after upgrade 2.7 (29 posts)

  1. matthijs
    Member
    Posted 11 months ago #

    There are many reports about permalink issues after upgrading, but none of the solutions worked for me. My situation and what I've done:

    - .htaccess is correct:
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    # END WordPress
    Double checked, even made it writable 777 and let wordpress rewrite the rules

    - permalink settings: checked /%category%/%postname%
    and saved them again. These always worked.

    - Plugins: all disabled

    The frontpage loads fine. The backend admin 2.7 works fine. I can edit all posts, all permalinks are there. Only trying to visit any page returns 404. going back to 2.6.5, everything works again.

    The only thing now that I can think of is the following: I developed this website locally. And then to publish the site I exported the database and imported it in the new host. That was a while ago, and it worked fine. Because I developed the site local, if you look at the permalinks in the database posts table, you will see them like
    http://www.localsite/somepermalink/
    while the one on the live site should be
    http://www.therealsite.com/somepermalink/

    I have set this in the wp-config file:
    define('WP_SITEURL', 'http://www.therealsite.com');
    define('WP_HOME', 'http://www.therealsite.com');

    This has always worked, with many sites. Could it be that this doesn't work anymore with 2.7?

  2. Ipstenu
    Member
    Posted 11 months ago #

    When you get the 404, does it give the 'expected' URL? Like http://www.therealsite.com/category/postname ?

  3. matthijs
    Member
    Posted 11 months ago #

    Yes I think so. Also when I try to access the pages with their non-clear urls, like ?p=24, it redirects to the clean url. But then I get the 404 from wordpress

  4. Ipstenu
    Member
    Posted 11 months ago #

    Is WP loaded in root or is it in a subfolder and you're using the 'trick' to put it in the root directory with the index.php file?

    This trick-> Giving WordPress Its Own Directory requires that you copy your .htaccess from your blog folder to the root folder (which it says, but I didn't do and screwed myself up for a while).

  5. matthijs
    Member
    Posted 11 months ago #

    yes, WP is loaded in root. Not in a subfolder.

    I just tried upgrading again, and again I get 404's on everything other then the home page.

    Before upgrading, I did an export from the db using phpmyadmin. I created a new testdomain locally. I imported the db into phpmyadmin locally. I then ran the upgrade from 2.6.5 to 2.7 locally, it works fine.

    I really don't understand what's going on. I double checked the htaccess, the config, everything. I upgraded at least 10 of my wp sites, all of them working fine. This one, not.

    Any other ideas?

  6. mrmist
    Member
    Posted 11 months ago #

    Sounds like the .htaccess isn't actually working.

  7. matthijs
    Member
    Posted 11 months ago #

    Yes, it seems like it. I just tested the site without pretty urls (?p=9 etc) and that works. But why the htaccess is not working is not clear. It worked fine before upgrading to 2.7. It works fine if I backgrade to 2.6.5

    But now with 2.7 it doesn't work anymore. I even tried uploading an empty .htaccess file, chmodding to 777, let WP write the file.

  8. matthijs
    Member
    Posted 11 months ago #

    Now I tried another thing: I created a complete fresh WP install in a testfolder on the same server. I get the same problem. Permalinks not working, every page/post returns 404

    Somehow the problem seems to be an interaction between WP2.7 and the htaccess file. Mod_rewrite and htaccess file alone works, as is shown by the working 2.6.5 install.

  9. mrmist
    Member
    Posted 11 months ago #

    Possibly something is still referencing the local site. I guess try the 2.7 again, go into admin - settings - general and change the WordPress address and Blog address and hit save changes - even if they are already correct. Then go through the permalinks starting with default and see if any of them work.

  10. matthijs
    Member
    Posted 11 months ago #

    Hi mrmist, thanks for the answer. Unfortunately, after doing what you suggested it still doesn't work. Even with the completely new install I get the same problem.

    I really have no clue here. The database is correct. The fact that a new fresh install has the same problem proves that it doesn't have to do with the database of the current site. The fact that a previous wordpress version 2.6.5 and earlier have no problems getting clean urls, proves that htaccess and clean urls do work on the webhost. So it seems to be some interaction betweenwp 2.7 and the webhost. But what?

  11. paul
    Member
    Posted 11 months ago #

    following this thread in hopes of an answer. I have the same problem, even on a test server running 2.5. No plugins, just an out of the box installation.

    The results are the same with WP, versions 2.5 through 2.7, on Apache 2.2 and php5 with MySQL 5 on either FreeBSD or OS X.

    Categories don't work (they never have, for some reason).

  12. matthijs
    Member
    Posted 11 months ago #

    I have some development in this issue: the webhost of the website changed a field in the wp_options table and that made the clean urls work. It's the field rewrite_rules, one of the first lines:
    From:
    a:71:{
    s:12:"robots.txt$";

    To:
    a:71:{
    s:11:"robots.txt$";

    I have no clue what this does, but it has something to do with apache. I'm trying to find out what it does, and whether this is a real fix or if the real problem lies in the configuration of the server.

  13. mrmist
    Member
    Posted 11 months ago #

    Ok I am running out of ideas. To see if it is to do with the redirection, you could try putting this on as a plugin -

    <?php
    /*
    Plugin Name: Disable Canonical URL Redirection
    Description: Disables the "Canonical URL Redirect" features of WordPress 2.3 and above.
    Version: 1.0
    Author: Mark Jaquith
    Author URI: http://markjaquith.com/
    */ 
    
    remove_filter('template_redirect', 'redirect_canonical'); 
    
    ?>
  14. mrmist
    Member
    Posted 11 months ago #

    If the plugin above does or does not work, it may be worth raising a bug on the trac, with this thread referenced, as it is looking like a 2.7 difference.

  15. matthijs
    Member
    Posted 11 months ago #

    That plugin didn't help either, unfortunately. What I did discover, was that the line of the rewrite rules I mentioned, seems to be incorrect after upgrading. I did a db dump before and after an upgrade from wp2.6.5 to 2.7 and noticed this diference:

    Before:
    INSERT INTO wp_options VALUES(636, 0, 'rewrite_rules', 'a:256:{s:11:"robots.txt$"; // ... line continues

    After:
    INSERT INTO wp_options VALUES(653, 0, 'rewrite_rules', 'a:304:{s:12:"robots.txt$"; // ... line continues

    I don't know what this all means, but to me from looking at the file it seems that the s:12 is supposed to be the count of the characters after it, between the quotes. And that count is 11 before (correct), but 12 after upgrade (incorrect).

    When I manually (in phpmyadmin) change the 12 to 11, the clean urls work. However, if I then go into the wp admin panel and do a save for the permalinks, it gets changed back into 12 again and the clean urls stop working again.

    So it seems that something goes wrong in the upgrade of that db table

  16. henselhosting
    Member
    Posted 11 months ago #

    Could have something to do with magic_quotes, that setting can add slashes making that field one char longer.

  17. matthijs
    Member
    Posted 11 months ago #

    That's it! Thanks for the help. This has been keeping me busy for more then a day.

    To summarize the problem and solution:
    - having magic_quotes_runtime and magic_quotes_sybase both ON in the PHP settings causes the permalinks not to work (anymore) in Wp 2.7.

    - setting
    magic_quotes_runtime = Off
    magic_quotes_sybase = Off
    solves the issue.

    The reason this might be a rare bug is probably that in most server settings these 2 settings are Off by default. But the fact that Wordpress does not check for these settings might be considered a bug/weakness of the wordpress code too. I will see if I can issue a ticket in Trac for this.

  18. MemoK
    Member
    Posted 11 months ago #

    I'm getting this problem too. I can't turn those off through .htaccess but editing the database solved the problem, temporarily.

  19. justinleon
    Member
    Posted 11 months ago #

    I tried to find "magic_quotes" or "rewrite_rules" in my databases and I can't find it.

    I am searching via phpmyadmin.

  20. matthijs
    Member
    Posted 11 months ago #

    @justinleon:
    You can read more about magic quotes in the PHP manual
    http://nl2.php.net/magic_quotes

    Setting both magic_quotes_runtime and magic_quotes_sybase to Off can be done in the server settings, if that possibility is there for you. With shared hosts, it's not always possible to change PHP configurations, in that case you should ask your webhost to do that.
    Here's the manual page about turning them off:
    http://nl2.php.net/manual/en/security.magicquotes.disabling.php

    If you can't change the server settings directly or your webhost won't do it for you, using a few rules in an htaccess file it's also possible to turn them off. See the same page in the manual.

    The "rewrite_rules" field can be found in the database table wp_options. It's one of the last records of that table. Changing that value manually in the database solved the problem for me as well, but as I mentioned, that's a bit of a messy solution. And each time you upgrade/save your permalinks in the wordpress admin panel again, the bug will return. So turning the magic_quotes_runtime and magic_quotes_sybase settings to Off is the best solution.

    I added a ticket to the wordpress Trac for this problem, as it would be better if there's a check in the wordpress code itself which would make sure that the code works, independent from which server setting someone might have.
    http://trac.wordpress.org/ticket/8757

  21. bunnzy
    Member
    Posted 10 months ago #

    Hey,

    I looked at the trac and it says this is resolved. But what about those of us who aren't allowed to change the setting on their shared provider? What can we do to get our blogs going, other than downgrading?

    I have now migrated to a new host, installed my wordpress and dang, none of my permalinks are working, which means none of my menus work etc.

    Is there a fix or workaround that will work for the rest of us?

    Thanks for any assistance.

    B

  22. paul
    Member
    Posted 10 months ago #

    Interesting. I wish it worked for me :-(

    I have those settings off in my db and I went in and diddled the rewrite_rules as suggested (they were consistent with what people have found to work properly).

  23. paul
    Member
    Posted 10 months ago #

    Maybe this is a little drastic, but I just deleted the rewrite_rules from my database and now things work. I had nothing to lose, so YMMV.

  24. matthijs
    Member
    Posted 10 months ago #

    @bunnzy: have you tried turning them off by your htaccess file?
    (see http://nl2.php.net/manual/en/security.magicquotes.disabling.php )

  25. BadEvan
    Member
    Posted 10 months ago #

    I know this may sound strange...

    download a copy of your .htaccess file and open it using notepad/wordpad.
    Is there a blank line at the beginning? If so remove it an upload it back to your root.

    Did that work? Cause that's what worked for me... no kidding.

  26. locusdelicti
    Member
    Posted 10 months ago #

    @matthijs, thanks for the detective work.

    I was experiencing the same issue, but phpinfo(); was saying magic_quotes_runtime and magic_quotes_sybase were both off. Then I decided to do a sitewide search for magic_quotes_* and sure enough, for some reason wp-config.php had this line:

    ini_set('magic_quotes_sybase', 1);

    Set it to 0 and problem solved. I guess you could also remove the line altogether.

    Hope this is useful!

  27. amenitya
    Member
    Posted 10 months ago #

    So...I tried both
    php_flag magic_quotes_gpc Off
    and
    php_value magic_quotes_gpc Off

    in the .htaccess file as recommended here. No luck.
    I set my permissions to 666 and let Wordpress rewrite- no luck.
    I added "category" and "tag" as suggested here. Nada.
    I uploaded the revised query.php lauded as the solution in this thread. Nope.

    Finally, I followed these instructions and remade the .htaccess again...Et voila. Success at last. HTH!

  28. frankganz
    Member
    Posted 6 months ago #

    @BadEvan... strange is right, but it WORKED! There was a blank linebreak at the beginning of my .htaccess file, I deleted it, saved, re-uploaded the file and it WORKED!!

    Thanks!

  29. frankganz
    Member
    Posted 6 months ago #

    Aw man. That was so close. Doing that broke a bunch of links everywhere in my blog. Back to the drawing board I guess.

Reply

You must log in to post.

About this Topic