Duplicate content problem


recently i used this rewrite rule

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

to make my URLs SEO freindly use them without the ext .PHP but ihave too many links i cant remove .php from all of them and search engines cant recanize that this link exmp.com/index.php and exmp.com/index is the same

how can i fix this i cant reject .php page to none .php pages manually cuz i have lots of pages and am working alone
and can i use rel=canonical to fix this

and thanks for helping


If you’re using that code in your .htaccess, that will affect all .php files in that directory. If you have .php files in other folders, you will just have to create a new .htaccess in each separate folder and paste all of the code that is in your main .htaccess.

This will fix all of the .php extensions and make all pages SEO friendly. No other code is necessary.