I have files with the extension .php and I’d like to hide them, as well as show querystrings as inner directories of the rewritten PHP extension.
In other words, I’d like https://domain.com/page.php
to be accessed with https://domain.com/page/ (with the ending slash) and for
https://domain.com/page/?id=1 to be accessed with
https://domain.com/page/1/ (also with the ending slash)
I’d also like access to the page with the .php extension return a 404 not found.
How would I do this in the .htacess file?
HTACCESS would need to look something like this:
For the custom 404 Error you would use:
However you will need to make sure that you apply the first rewrite rule to the 404 page.
You will need a
404.phpfile.