• Resolved futurepocket

    (@futurepocket)


    I am trying to change the permalinks on my blog… but the auto 301 redirect in WordPress is not working… it’s not even giving me any errors at the bottom after I updated the permalinks but when I try to navigate to the old permalink structure, it just gives me a 404 error and does not redirect to the new post. Any ideas what could be causing this? I’ve checked my .htaccess file and the necessary code is already there (if it wasn’t, wouldn’t the permalinks setting inform me)?

    Please help asap!

Viewing 10 replies - 1 through 10 (of 10 total)
  • Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    if it wasn’t, wouldn’t the permalinks setting inform me

    The settings page will tell you when it can’t write to the .htaccess file and gives you what to paste in if that’s the case. But it doesn’t (can’t really) check if there is something before it that might be interfering.

    If it’s not too many lines (10 or less would be ideal) can you post the whole contents of your .htaccess file here?

    If it’s more than that, please use pastebin.com and post the link to your paste.

    esmi

    (@esmi)

    Check with your hosts that mod_rewrite is running on your server.

    Thread Starter futurepocket

    (@futurepocket)

    https://pastebin.com/t8PF6urm

    That’s the whole .htaccess file. Could you please tell me what is supposed to be a part of that file and what isn’t? Looks like there is more in there that needs to be and I have NO idea how it got there — except the WP Super Cache of course.

    @esmi, yes, mod_rewrite is running (checked via <?php phpinfo(); ?>) and asked host as well.

    Thanks guy!

    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    There is a lot going on in that file.

    Just for process of elimination try the following:

    Make a backup of that .htaccess file. Call it .htaccess-old.

    With that backup saved (no really, make a copy), delete all the lines except these.

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress

    Then

    – disable all of your plugins

    – switch to the Twenty Eleven theme

    – Reset your permalinks (save them again)

    Visit your site and see if that makes a difference for your permalinks, meaning see if you still get 404 errors.

    Thread Starter futurepocket

    (@futurepocket)

    Did everything you said… deactivated all plugins (including WP-Super Cache)… made a new .htaccess file with just that code, switched to the Twenty Eleven Theme and reset the permalinks but still got 404 error on all old permalink structures … it did not auto redirect to the new %postname% structure.

    Any other advice or way to check what could be wrong?

    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    *Jan re-reads from the top*

    when I try to navigate to the old permalink structure, it just gives me a 404 error and does not redirect to the new post

    I think I’ve misunderstood your problem.

    Are permalinks working correctly on your site but the old one’s aren’t redirecting to the new ones?

    If yes, can you paste here an old link with the new?

    Thread Starter futurepocket

    (@futurepocket)

    Yes, you may have misunderstood the problem. I am trying to change my permalink structure but the old permalink structure is not 301 redirecting to the new one. I have temporarily changed the permalink structure to the new one (for you to test) but will change it back soon if I can’t get it fixed as I don’t want a bunch of broken links on the website.

    OLD STRUCTURE:

    https://futurepocket.com/2012/02/25/make-money-playing-games-and-doing-surveys/

    NEW STRUCTURE;

    https://futurepocket.com/make-money-playing-games-and-doing-surveys/

    You see when you go to the old structure, it should redirect to the new one but it doesn’t. Thanks for your help!

    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    Okay, that’s weird. The canonical URLs should have taken care of that but it’s not.

    More .htaccess work. With that backup firmly in place add this to the top of your .htaccess file.

    # Old URLs to new
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^([0-9]{4})/([0-9]{2})/([0-9]{2})/(.*)/$ https://futurepocket.com/$4/ [L,R=301]
    </IfModule>

    Put that at the very top of your file and save that.

    Then try visiting https://futurepocket.com/2012/02/25/make-money-playing-games-and-doing-surveys/ and see if it works.

    Thread Starter futurepocket

    (@futurepocket)

    Works perfectly!! What was the problem exactly? Should I remove the other junk from my .htaccess (the other rewrite rules auto inserted by WordPress)?

    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    I’m not sure what the problem was, I thought canonical URLs would have taken care of it for you. It’s an old feature.

    https://markjaquith.wordpress.com/2007/09/25/wordpress-23-canonical-urls/

    On my test install when I change my permalink structure as you did, WordPress is able to figure out what the real URL is/should be and 301’s the browser on it’s way.

    That wasn’t happening with you, so that rewrite rule being added at the top ensures that the rewrite happens and the browser gets to where it needs to go.

    Once search engines stop sending people to your old URLs, you can remove those lines from the top.

    Edit:

    Should I remove the other junk from my .htaccess (the other rewrite rules auto inserted by WordPress)?

    I’m not sure. The WP SuperCache additions should be fine, but I don’t know about the rest. If everything works I suggest leaving there.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Permalink Redirect Not Working?’ is closed to new replies.