How do you edit the .htaccess file

Before you upload an .htaccess file to your server, make sure there is not already one there. Your host panel or perhaps a script you have uploaded may have already changed the htaccess for some reason so you don’t want to overwrite it as doing so could change something important on your site. For example, in cpanel, you can setup 301 redirects very easily but this tool is simply a script which changes the .htaccess for you. So even though you may not realise it, when you use the redirect script via cpanel, it updates your .htaccess file for you and it’s the .htaccess file which controls the redirect for you (the redirect tool just makes it easier for those who are not familar with .htaccess).

So if there is an .htaccess file there already, you want to download that and edit it before reuploading. This will ensure that nothing you have setup previously is changed.

If there is no .htaccess file there then you need to create one. Thankfully, this is very easy to do. All you need to do is open a text editor and save a blank document as .htaccess. Save the file exactly as it is stated there in bold ie. there is no writing before the extension. You need to save it as .htaccess and not htaccess.txt or document1.htaccess or whatever.

When uploading you should always :

  • Upload in ASCII mode, not binary
  • CHMOD the file to 644 (this isn’t absolutely necessary per say but it’s advisable, it means your server can access it but it can’t be seen via a browser).

Written by 

I am Sakthivel Madesh, a certified Salesforce Advanced Developer & Administrator working on Salesforce Technology since 2011. I am currently working in Techforce Services as Sr. Salesforce Developer. I have worked on multiple technologies Like PHP, Java, Salesforce, I am very passionate about Salesforce and to earn 15x Salesforce Certification. I love Trailhead for learning Salesforce Skill and Become a Trailhead 5x Ranger too. I Love to Learn & Share my Salesforce knowledge to Salesforce Learners/Beginner using My Blog and Salesforce Community.

Leave a Reply

Your email address will not be published. Required fields are marked *

*