Remove .php extension except from a file

1

Hello

I have my system in php, I added the .htaccess file

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.*)\.php
RewriteRule ^ /%1 [L,R=301]

It worked fine, but I wanted it not to remove the extension only from index.php

Thank you in advance

    
asked by anonymous 26.01.2017 / 22:02

1 answer

2

This way it can solve for you. See:

# index.php > index (visível, exceto para index.php)
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/(.+)\.php[^\s]* [NC]
RewriteCond %{REQUEST_FILENAME} !index\.php
RewriteRule ^ /%1 [R=301,NE,L]

See this SOen response .

  

.htaccess files provide a means of making changes in the   settings per directory.

Reference

26.01.2017 / 23:01