0

I have specific files like file.php that I want to rename to file and then execute with PHP. Is it possible to do that with .htaccess?

For example, if I have files named file, file2 and file3 I want only file executed with PHP, not all files without extension.

user1227914
  • 3,446
  • 10
  • 42
  • 76

1 Answers1

0

You can use this. I put in a few extra checks as well so it will ignore all files that start with a number.

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/file([0-9]) [NC]
RewriteCond %{DOCUMENT_ROOT}/file.php -f
RewriteRule ^file/?$ /file.php [L,QSA]
Panama Jack
  • 24,158
  • 10
  • 63
  • 95