Skip to content

Instantly share code, notes, and snippets.

@apphp
Created February 3, 2014 09:42
Show Gist options
  • Select an option

  • Save apphp/8781048 to your computer and use it in GitHub Desktop.

Select an option

Save apphp/8781048 to your computer and use it in GitHub Desktop.
Remove File Extention from URLs in .htaccess
/*
This example shows you how to remove file extension from URLs using .htaccess file directives. Remember, that "mod_rewrite" works only on Apache server. Before trying please be sure that you are working on Apache server and the "mod_rewrite" module/extension is enabled.
Source: http://www.apphp.com/index.php?snippet=htaccess-remove-file-extention-from-url
*/
# Sample 1:
RewriteRule ^about$ about.php [L]
# Sample 2:
RewriteCond /%{REQUEST_FILENAME}.php -f
RewriteRule ^([a-zA-Z0-9_-\s]+)/$ /$1.php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment