how to remove o.php with .htaccess

0

Well I'm used to calling the following link with my apache:

index.php?variavel1=1&variavel2=2

How can I make my .htaccess identify the following link:

index?variavel1=1&variavel2=2

And switch to:

index.php?variavel1=1&variavel2=2

That way I would hide .php

    
asked by anonymous 20.06.2016 / 19:56

1 answer

2

I think this may be the way:

RewriteEngine On

# Unless directory, remove trailing slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/$ http://example.com/folder/$1 [R=301,L]

# Redirect external .php requests to extensionless url
RewriteCond %{THE_REQUEST} ^(.+)\.php([#?][^\ ]*)?\ HTTP/
RewriteRule ^(.+)\.php$ http://example.com/folder/$1 [R=301,L]

# Resolve .php file for extensionless php urls
RewriteRule ^([^/.]+)$ $1.php [L]

Retired from here: alexican.com

    
20.06.2016 / 19:59