Hello,
There's a way to do what you want.
But how do you know which links must be redirected to a .php file on your server?
WordPress for example does it by taking all Request URIs and redirecting them internally to its index.php file.
Then the WordPress index.php file has a well-defined set of Request URI patterns and which .php file to redirect them to.
Here I'm going to simply think that you have a dedicated host on your server where any file without extension should be redirected to a .php version if available.
The URLRewrite method:
Example URI:
/folder-1/folder-2/folder-3/script-file/?key-1=value-1&key-2=value-2
RegEx pattern:
^(?!.*?\.php(?:\/$|\/\?.*|\?.*|$))(.*?)(\/|)(\?.*|$)$
RegEx replacement (redirect to):
$1.php$2$3
End result (redirected to):
/folder-1/folder-2/folder-3/script-file.php/?key-1=value-1&key-2=value-2
* this RegEx pattern will silently ignore requests that already have a .php file extension.
How to:
Create one URLRewrite rule:
Do as shown above, relative to base for
/.
Uncheck 'Apply to subrequests' and set the redirection to 'Internal redirect'.
The conditions should be REQUEST_FILENAME is not a file & is not a folder.
This is not case-sensitive.
-
However, how will you hide .php from your existing .php script redirects?
If you have a .php script that automatically does a 302 redirect with header("Location:
https://mysite/another-script.php?key=value"), then you also have to modify your .php scripts to remove the '.php' text in any HTTP redirect you might find.
-
For handling 404 errors incase of non-existing files, you might want to use a custom 404 page (Error pages section of Abyss) to hide the .php extension from there as well so that it doesn't show up in visitor error pages.