Created
July 7, 2021 14:15
-
-
Save Cristy94/f877f0e00f0569666cb71348b6591a25 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Remove .php extension | |
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\ (.*)\.php [NC] | |
RewriteRule ^ %1 [R=301,NE,L] | |
# Check whether the file exists then set it back internally | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_FILENAME}.php -f | |
RewriteRule ^.*$ $0.php [L,NE] | |
## Notes: | |
## [NE] - NotEscape flag is needed so the redirect works with UTF8 URLs (eg. Chinese character) | |
## The first block removes the .php extension, the second one serves the correct file when the extension is missing | |
## ^[A-Z]{3,}\ - Skips the POST or GET method from the HTTP request (THE_REQUEST) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment