Apache’s rewrite module is a very powerful tool for manipulating URLs. Taking a look at the mod_rewrite documentation can be overwhelming, especially if you are only looking to hide that ugly PHP file extension from your URLs. For the sake of simplicity, we’ll focus on that but keep in mind this module is complex and there’s a lot more to it.

Navigate to /etc/apache/site-available/ and edit your site’s configuration file. Inside the Virtual Host’s Directory directive we will add two lines.

This rule uses a regular expression to find any one resource with the extension .php and removes the extension. Multiple rules can not be applied using this configuration; although, they are possible. You may alternatively substitute $1.php for $1.html to remove HTML file extentions. Restart Apache with the following command.

Let’s say you have an index.php file, you should be able to load http://example.com/index.

About Canadian Web Hosting

Since 1998, Canadian Web Hosting has been providing on-demand hosting solutions that include Shared Hosting, Virtual Private Servers (VPS), Cloud Hosting, Dedicated Servers, and Infrastructure as a Service (IaaS) for Canadian companies of all sizes. Canadian Web Hosting is SSAE 16 Type II SOC 2 certified, ensuring that their processes and business practices are thoroughly audited against industry standards. Canadian Web Hosting guarantees a 100% network uptime, and a total money-back guarantee that backs everything they do. Customers can get help by calling 1-888-821-7888 to get 24/7 support. For more information, visit them at www.canadianwebhosting.com, or get the latest news by following them on Twitter at @cawebhosting.