1

I am using

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

in .htaccess file.

It works ok in that www.site.com/about shows the about.php page, but it still allows users to strictly specify .php, for e.g. www.site.com/about.php does not strip the .php.

Is it possible to do this, so even when they type the .php extension it strips it but still shows that page?

Thanks

1 Answer 1

1

You can add this rule before your current rule:

RewriteCond %{THE_REQUEST} \s/+(.*?)\.php[\s?] [NC]
RewriteRule ^ /%1 [R=301,L,NE]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.