Remove File Extention from URLs in .htaccess


/ Published in: PHP

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.


Copy this code and paste it in your HTML
  1. # Sample 1:
  2. RewriteRule ^about$ about.php [L]
  3.  
  4. # Sample 2:
  5. RewriteCond /%{REQUEST_FILENAME}.php -f
  6. RewriteRule ^([a-zA-Z0-9_-\s]+)/$ /$1.php

URL: http://www.apphp.com/index.php?snippet=htaccess-remove-file-extention-from-url

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.