I have a WordPress site that has 4 old .php pages left to run as is. My issue is previous there was a rewrite rule to remove the .php from the URL giving it clean URLs.

I tried just adding the same rules above and below the WordPress code in the .htaccess, but it would give a redirect loop.

# remove .php extension
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^(.*?)/?$ $1.php [L]

How can I preserve access to these 4 pages using the URLs with out .php ?

1 Answer 1


It should work with this lines which simply remove the .php from files that end with .php:

RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule !.*\.php$ %{REQUEST_FILENAME}.php [QSA,L]
  • That worked perfectly, thank you! WordPress pages still work fine (w/ pretty urls) and my .php pages work without .php.
    – JamesM
    Commented Jul 31, 2015 at 4:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.