Currently, I have my htaccess on WordPress setup like this:
#I want to prevent any .php 301 redirects in wp-admin, wp-includes, wp-content
RewriteCond %{REQUEST_URI} !^(.*)?wp-login\.php(.*)$
RewriteCond %{REQUEST_URI} !^(.*)?wp-admin$
RewriteCond %{REQUEST_URI} !^/(wp-includes/.*|wp-admin/.*|wp-content/.*)$
#I used the standard WordPress htaccess along with the .php redirect
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteRule (.*)\.php$ /$1 [R=301,L] #this does the 301 redirects with .php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
I am looking to 301 redirect my old .php site to WordPress, for example anything that has ".php" will be redirected to "/" without effecting wp-admin, wp-content, wp-includes original functionality.
wp-admin, wp-includes, wp-content - are dependent on .php and they can't be redirected or it will create a 404 error / missing page.
THE PHP FIX: I created a temporary fix with PHP and it's working perfectly, I added this to theme/function.php on the first line:
$link = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$admin_url = ["wp-admin", "wp-includes", "wp-content"];
$count = 0;
$admins = '';
foreach ($admin_url as $url) {
if (strpos($link, $url) !== false) {
if($count === 0){
$admins = "admins";
$count = 1;
}
}
}
if (strpos($link, '.php') !== false && $admins == '') {
wp_redirect( str_replace('.php', '/', $link) );
exit;
}