how to remove.php with . htaccess

Asked

Viewed 1,070 times

0

Good guys I’m used to calling the following link with my apache:

index.php?variavel1=1&variavel2=2

Can I make my . htaccess identify the following link:

index?variavel1=1&variavel2=2

And trade for:

index.php?variavel1=1&variavel2=2

That way I would hide . php

  • Yes there is possible, search on url friendly can help a lot.

1 answer

2


I think this might 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]

Removed from here: alexican.

  • I took a look here and I don’t understand very well. I wanted to take the ? of my url and exchange for . php

  • so your question is a little confused, because what I understood would be that you would like to remove . php from your Urls

  • well the goal and that same, I will try to explain myself better ok. I tried to use your code, however I got the following error: Internal Server Error am trying to call the file like this: 127.0.0.1/index

  • I got here vlw ;)

Browser other questions tagged

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