Overview
You can control how file extensions behave on your website — adding an alternative extension, forcing other extensions to load as PHP, removing an extension, or allowing a file to load without its extension — by adding code to your .htaccess file.
Creating an .htaccess file on your DreamHost web server
See this article for instructions on how to create an .htaccess file on your web server.
If the file already exists, see the following articles for instructions on how to update it (depending on if you're using an FTP client or SSH):
How do I control a file extension?
The examples below provide several options to adjust file extensions on a website.
These code examples can be entered into your .htaccess file exactly as shown.
You only need to update the highlighted code to your actual URL. For example, if you see the domain example.com, change this to your own domain name.
How do I change a file extension?
This example allows you to use a .zig extension in addition to the regular .php extension. So, you could access a file at example.zig as well as example.php:
Options +FollowSymlinks RewriteEngine On RewriteBase / RewriteRule ^(.+)\.zig$ /$1.php [NC,L]
How do I force other file extensions to load as PHP?
See this article for several examples of how to force any file extension to load as a .php file.
How do I remove a file extension?
The following completely removes the file extension from your URL. So, example.php would appear as example. This example is for .php files, but you can use it for any other type by replacing .php with your desired extension:
RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\ HTTP/
RewriteRule ^(.*)index$ http://example.com/$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/$ http://example.com/$1 [L,R=301]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.+)\.php\ HTTP/
RewriteRule ^(.+)\.php$ http://example.com/$1 [L,R=301]
RewriteRule ^([a-z]+)$ /$1.php [L]
How do I allow a file to load without its extension?
This example does not automatically remove the file extension. However, it does allow the file to be loaded without the extension. So, if example.com/test.php exists, you can then load it as example.com/test:
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+)$ /$1.php [L,QSA]