• Resolved John Dimick

    (@johndimick)


    If I change my blog’s permalink URL structure, shouldn’t I see a change in the .htaccess file? I’m not seeing it.

    The old URL structure:
    http://www.domain.com/blog/year/month/postname/.

    The newly modified permalink URL structure:
    http://www.domain.com/blog/postname/.

    404’s are coming when external links use the old structure. The .htaccess is supposed to take care of this, right?

    I have this in .htaccess:

    # 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

    But it’s not working. I’m getting 404’s from external links that have the old structure.

    I noticed at the bottom of WP admin settings>permalinks page there was a message saying “If your .htaccess file were writable, we could do this automatically, but it isn’t so these are the mod_rewrite rules you should have in your .htaccess file.”

    So I manually copied the rules to .htaccess. Still no joy. Then I fixed the .htaccess permissions. The WP admin message went away, which means WP is now able to write to .htaccess, right?

    Then, realizing WP is installed in a subdirectory – http://www.domain.com/blog/ – I wondered if the .htaccess should be as follows:

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

    I entered that manually in .htaccess and it made no difference. Same 404’s.

    Finally, hoping to see if WP was even writing to the .htaccess, I changed the custom permalink structure to:
    http://www.domain.com/WTF/postname/ in WP admin. No changes showed up in .htaccess.

    I’m out of ideas. I’d like to at least establish why WP doesn’t seem to be writing to .htaccess. My host is Pair.com. I’m pretty sure they allow Apache mod_rewrite.

Viewing 9 replies - 1 through 9 (of 9 total)
  • Check with your hosts that mod_rewrite is running on your server.

    Thread Starter John Dimick

    (@johndimick)

    I just got them on the phone. The server IS running mod_rewrite. And while I had them on the line I had them watch the time-stamp on the htaccess while I fiddled with permalinks. Nothing changed. WP doesn’t seem to be talking to that file. We even opened up 777 permissions on the file for a minute to make sure there was no problem in that department.

    What happens if you switch to the plain (default) permalink structure?

    Thread Starter John Dimick

    (@johndimick)

    Just tried that. Every permalink, new or old, now redirects to the site home page. Also, no change is seen in the .htaccess file.

    Thread Starter John Dimick

    (@johndimick)

    Let me be more specific: every external link with an old permalink structure redirects to the home page (prolly because of 301 redirects higher up in the htaccess). The just-now-configured default permalinks work as they should.

    Thread Starter John Dimick

    (@johndimick)

    Whoa, waitaminnit! I just switched back to custom permalinks and everything is working now! Switching to “plain” and back did the trick. Cool. Thank you. 🙂

    No problem. 🙂

    It was probably just a damaged .htaccess file. Sometimes, the file can be re-written by simply navigating to Settings -> Permalinks but switching to plain permalinks and then back to custom ones can provide some valuable troubleshooting info in more complex cases.

    Thread Starter John Dimick

    (@johndimick)

    I had to change this topic back to Unresolved. Hope that’s ok.

    Yesterday’s fix worked fine, as far as it went, but it returns a 404 if there’s a .html extension involved. All the external links to my posts over the past 10 years have the .html extension.

    After digging into this site, there seems to be a consensus that adding the following to .htaccess is the fix:

    RedirectMatch 301 /\d{4}/\d{2}/(.*)\.html http://example.com/$1

    I tried that, but forgot to replace example.com with my domain, so it redirected to example.com. Literally. So I replaced example.com with my domain and tried again — and still was redirected to example.com.

    Caching problem?

    My blog is http://www.guitarist.com/blog . I’m leaving the post permalinks set for .html for now, but I’d like to be able to strip that extension away.

    Oh, and I tried the reset trick several times.. 😉

    Thread Starter John Dimick

    (@johndimick)

    Too complicated. Giving up. Will just leave the .html on.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Trouble with permalinks and .htaccess’ is closed to new replies.