Created
April 7, 2020 05:14
-
-
Save JulaineScott/f19ceebd72ef65eec473adab5c914866 to your computer and use it in GitHub Desktop.
Change php files to slugs
This file contains 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
#1)externally redirect "/file.php" to "/file" | |
RewriteCond %{THE_REQUEST} /([^.]+)\.php [NC] | |
RewriteRule ^ /%1 [NC,L,R] | |
#2)Internally map "/file" back to "/file.php" | |
RewriteCond %{REQUEST_FILENAME}.php -f | |
RewriteRule ^(.*?)/?$ /$1.php [NC,L] |
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule (.) $1.php [L]
#if no file, send to 404
RewriteCond %{THE_REQUEST} "^[^ ] .?.php[? ].$" RewriteRule .* - [L,R=404]
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
from https://stackoverflow.com/questions/4908122/removing-the-php-extension-with-mod-rewrite