Created
March 6, 2014 20:38
-
-
Save travismillerweb/9399170 to your computer and use it in GitHub Desktop.
Apache - Remove .php from File URL
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
## Remove .php from File URL | |
## Reference Link: http://stackoverflow.com/questions/15917258/remove-php-from-urls-with-htaccess | |
# Turn mod_rewrite on | |
RewriteEngine On | |
RewriteBase / | |
# To externally redirect /dir/foo.php to /dir/foo | |
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC] | |
RewriteRule ^ %1 [R,L] | |
# To internally forward /dir/foo to /dir/foo.php | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteCond %{REQUEST_FILENAME}.php -f | |
RewriteRule ^(.*?)/?$ $1.php [L] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment