Matt
Matt

Reputation: 1570

Append `.php` extension to URL?

I'm not familiar at all with the process behind this, but what I would like is to have a rule in the .htaccess file that will append .php after a URL IFF the URL is indeed a file.

I have:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php

for the redirecting if a user types in the URL without the .php extension, but in addition to the redirect, I would like to actually append the URL with the .php extension. Is this possible?

Upvotes: 0

Views: 316

Answers (1)

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798676

You will need to use the R flag so that the client is instructed to redirect to the new URL.

Upvotes: 1

Related Questions