Remove . php extension except from a file

Asked

Viewed 197 times

1

Hello!

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

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 very well, but I wanted you not to remove the extension only from index.php

Thank you in advance

  • It is difficult to change the context of the question after answered. Your change has changed a bit the sense that was asked. This is a waste of the time of colleagues who stop to read and help, I recommend that next, try to elaborate better so that you already get what you want.

  • I really didn’t pay attention, but so I’ll learn, thanks for the tip

  • doubled with the new one: http://answall.com/questions/180379

1 answer

2


This way 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]

Look at this reply on Soen.

Files . htaccess offer a way to make changes in directory settings.

Reference

  • and folder functions also rsrs type system/functions within that folder also files remain with extensions

  • @Would Carlos be an additional question or could it be another question? hehe

  • is because I didn’t know how to express myself

  • @Carlos tries in other questions not to add anything that will influence the answers given. It’s not very interesting, because most of the time it invalidates the answer.

  • blz. Thank you! Sorry there

Browser other questions tagged

You are not signed in. Login or sign up in order to post.