Url rewrite with htaccess

Your first order of business should be updating the links in your imported content so that people aren’t given links to the old URLs in the first place. This should be pretty easy to do with an SQL replace. For your situation, it’d be something along the lines of:

UPDATE wp_posts SET post_content = REPLACE(post_content, '.php', "https://wordpress.stackexchange.com/");

You gotta be realy careful with find/replaces though, as they sometimes replace things you didn’t anticipate. It’s a good idea to back up your DB before doing anything like this.

As for an htaccess fix: it’s definitely a good idea to do 301s for the old URLs if you have a lot of inbound links, which translate to SEO value. But the amount of work you put into this should be proportional to the value of those inbound links.

I’m thinking it’s not a good idea to try to rewrite ALL .php requests, as WordPress often needs to make legitimate ones. For example, all requests on the frontend are routed through index.php, and when I tried setting up a rule like the one you asked for, it broke WordPress altogether. Know what I’m saying?

An alternative is to set up individual rules for each page you want to 301. Of course, this might be a bad idea if you have a LOT of links–both because it’s a hassle, and could impact performance.

Hopefully someone else has a tricky htaccess workaround for you, but I’m stumped.