Support » Fixing WordPress » .htaccess redirect from generic .html link to .php?

  • Resolved jonag


    I moved my blog from MT to WP and was able to preserve the permalink structure:

    Old MT permalinks: “”

    New WP permalinks: “”

    But I have not succeeded in creating an htaccess redirect so that people who find a link to one of my old MT posts on Google are automatically sent to the php version of that link. I also want to redirect Google links to my old blog’s MT comments, which take the form “”, to “” (i.e., I want the comment ID string to be stripped from the URL, and the URL then converted to php format).

    My current .htaccess file (which doesn’t work for html-to-php redirection) is:

    <IfModule mod_rewrite.c>
    RewriteEngine On
    # WordPress rules: redirect not-found file or directory to index.php.
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    # Redirect any .html page to the corresponding .php page.
    RewriteRule ^(.*).html$ $1.php [L]

    I’d be grateful if anyone could show me how to perform the generic htaccess redirects I’m asking about. Thanks.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Actually, in WP you don’t have .php extension on posts, for example. So, how do you get those
    archives/001234.php URIs?

    In the options/permalinks section of my WP control panel, I specified the following customized permalink structure:


    I specified this permalink structure partly because I thought it would make redirects easier to set up.

    So, did you try
    /archives/%post_id%.html – if that’s what you want?

    No, in my ignorance I assumed that only php extensions would work. But I just tried it and it works fine. Does substitution of html for php extensions change the functioning of my WP site?

    It shouldn’t. All that “extension” is not real – the core files and the template files etc. still are php files and they work. Should I say… hmmm… it’s a “virtual extension”? 😉

    No – see here.

    Thank you both very much!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘.htaccess redirect from generic .html link to .php?’ is closed to new replies.