How to change a file extension

Overview

It's sometimes necessary to change a file extension to ensure it functions as intended. For example, if you create a text file on your computer, it's saved with the extension of .txt

If the file needs to be a phpinfo.php, .htaccess, or phprc file, the extension must be changed or removed. This article explains how to adjust the file extension.

This article assumes you have already created or uploaded the file to your website at DreamHost. View the following articles for instructions on how to upload your file or create it on the server:

Editing the file extension in Filezilla

These instructions assume you've uploaded the file to DreamHost using the links above. Once the file is on the server, log in using an FTP client such as Filezilla.

Right click on the file and choose 'Rename'. Edit the file to remove the .txt extension. Click 'Enter' and the file is immediately saved with the new extension.

Editing the file extension via SSH

These instructions assume you've uploaded the file to DreamHost using the links above. Once the file is on the server, log in using your Shell user:

Once you have logged into your server via SSH, navigate to the location of the file. You can then rename the file to remove the extension. For example, the following command changes a file titled from phpinfo.php.txt to phpinfo.php:

[server]$ mv phpinfo.php.txt phpinfo.php

This example shows how to remove the extension while also renaming it:

[server]$ mv php.ini phprc

You can then run ls -la to confirm it's been renamed:

[server]$ ls -la

See also

Did this article answer your questions?

Article last updated PST.

Still not finding what you're looking for?