Report this

What is the reason for this report?

how to create fresh .htaccess in site's root access directory?

Posted on September 6, 2021

how to create fresh .htaccess in site’s root access directory?



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi @faizytheace,

To create your .htaccess file, you’ll first need to SSH to your droplet. Once inside, if you are not sure where is your DocumentRoot folder of your domain, you’ll need to open your Apache config.

The Apache config is located in /etc/apache2/sites-enabled. Usually, the file would be called just like your domain but in some cases, the file would be called default.

Once you are sure which file it is, you can use cat to see the content of the file and list it. In there you’ll see the DocumentRoot folder:

cd /path/to/website
touch .htaccess
nano .htaccess

That’s it, you can now edit the file.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.