.htaccess is amazing! If you haven’t read the introduction to .htaccess, check that out first (Unless you already know the amazing things .htaccess can do). Remember that .htaccess files are used only on Apache web servers.
Creating a .htaccess file can be tricky, as some systems don’t want the name to start with a dot. For example, Chrome OS and Windows do not allow it at all! Fortunately, your FTP software allows it, and that is all that matters. Once you create the file in your FTP software, you can download it to your computer and edit it there (Sometimes, however, the system still won’t like it. For example, Chrome OS removes the dot, making it useless). The solution? Build your .htaccess file on your computer, but name it “htaccess.txt”. After you are done creating or editing it, upload it to your web server, then rename it to “.htaccess”.
IMPORTANT! Permissions for .htaccess files must be set to 755. Check your CHMOD settings if your .htaccess is not working properly.
Many systems don’t allow filenames starting with a dot, so that restricts how we can create a .htaccess file. We can get around it though, so here are the steps again in case you missed them, or got confused.
Note: An .htaccess file located in a sub-directory overrides any duplicate rules from previous .htaccess files. For example, if you have a .htaccess file located in the root defining a 404 and 403 error page, and another .htaccess located in the “test” folder defining only a 404 error page, any files and folders in the “test” folder will use the 404 page defined in the "test" .htaccess file, and the 403 page defined in the root .htaccess file.
Just like creating a .htaccess file, sometimes you have to get around restrictions (If you're lucky enough to not run into any, just download the file, edit it, then re-upload it!). If you need to edit it, and files starting with a dot are restricted by your OS, remember to rename it back to “htaccess.txt” before downloading! Here are the steps again, just in case you got confused.
Now that we have the basics out of the way, we can start building! Visit the list of things you can do with .htaccess to get started, or get started by setting up your custom error pages. Have fun!
It’s always a good idea to disable image hotlinking. Image hotlinking is when someone else displays your image on their website, but they embed it from your site. This means that visitors to this othe...
Have some amazing content on your website? Since you're here, you probably know what caching is (If you don’t, it’s the fact that your computer saves copies of webpages, so you can view them later wit...
All code and content © 2023. Contact Us to learn more.