WordPress rebuild – 301 redirect old pages (*.php) to pretty permalinks

Here is what I need to do:

old pages are mydomain.com/something.php

Read More

new pages are rebuilt in WordPress identified using pretty permalinks so they are mydomain.com/something/

I need to figure out what the rewrite rule should look like. I have crawled the web and can’t find anything exactly like it.

Related posts

Leave a Reply

2 comments

  1. Something like:

    RewriteEngine On
    RewriteRule   ^(.*).php$ $1/ [R=permanent]
    

    The (.*) is a “group” of characters before the .php, and $1 refers to that group of characters. So just add a slash to the group and send the browser to the new URL with an HTTP code 301 (permanent redirect)

  2. Try this:

    RewriteEngine On
    RewriteBase /
    
    #Ignore index.php 
    RewriteCond %{REQUEST_URI} !index.php
    RewriteCond %{REQUEST_URI} !(wp-login|wp-admin|wp-includes)
    RewriteCond %{REQUEST_URI} ^(.*).php$
    RewriteRule ^(.*).php$ $1/ [R=301,L]
    
    #"Standard" WordPress Rewrite Stuff
    RewriteRule ^index.php$ - [L]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} !/catalog
    RewriteRule . /index.php [L]