0

How do I remove or hide php extension? using .htaccess?

2 Example URL :

http://localhost/folder/test.php?id=1&company=ABC&address=AAAAA

http://localhost/folder/test2.php?username=abcd

Thank You

1
  • 1
    Please do some basic research before asking. Your question title, typed verbatim into either Google or this site’s own search, would have gotten you plenty of results already. Commented Oct 17, 2018 at 8:02

1 Answer 1

1

Add this code in .htaccess for html and php extension

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L] //for php extension
RewriteRule ^([^\.]+)$ $1.html [NC,L] //for html extension

for query string add these lines Try this

  RewriteRule ^(folder)/(\d+)/([^/.]+)$ test.php?id=$1&company=$2&address=$3 [L]

Try This

RewriteRule ^(folder)/(\d+)/([^/.]+)$ test?id=$1&company=$2&address=$3 [L]

Try this

RewriteRule ^/?([a-zA-Z_]+)/([a-zA-Z_0-9]+)$ test?id=$1&company=$2&address=$3 [L]
RewriteRule ^/?([a-zA-Z_]+)/([a-zA-Z_0-9]+)$ test2?username=$1 [L]

i have add every possible solution

Sign up to request clarification or add additional context in comments.

3 Comments

2nd url work fine but for url 1st I received an error.. Object not found! The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again. If you think this is a server error, please contact the webmaster.
@twister i have update my answer. check and update if this possibilities work or not work
same result..if I enter the url with no php extension it will be redirect to this url localhost/test?/id=1&company=ABC&address=AAAAA folder auto missing..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.