Skip to main content

A Beginner’s Guide to .htaccess for Designers and Developers

www.hongkiat.comhongkiat.com2 weeks ago in#Design Love44

Among the various tools for customizing your web server, the .htaccess config file is a tremendous asset. You can quickly reset document types, parsing engines, URL redirects, and many other crucial features. Designers or developers who are not very technical may not get into the specifics of managing their own .htaccess file. But the topic itself is fascinating and worth some investigation. For this article, I want to present some more purposeful concepts for designers and developers. Anybody who is launching their own website on an Apache server will want to understand how to manage their .htaccess file. It provides so much customizability and it can work across pretty much any web programming languages. At the bottom of this post I have added some external web apps to help newcomers generate their .htaccess files dynamically. Why use an .htaccess File? This is a great question and perhaps we should start by answering “what is a .htaccess file“? .htaccess is a very special configuration file used by the Apache web server. They can tell the web server how to present various forms of information and how to handle various HTTP request headers. Really it is a means of decentralization to organize web server settings. One physical server may hold 50 different websites, each with its own .htaccess file. It grants a lot of power to webmasters, which would otherwise be impossible. But why should you use one? The biggest reason is security. You can lock out certain directories or make them password protected. This is great for private projects or new CMS (Content Management Systems) where you want a little extra security. But there are also common tasks like redirecting 404 error messages to a certain webpage. This only takes a single line of code, and it can dramatically impact how visitors react to missing pages. Truthfully, there is not much I can say to convince others that a .htaccess file is worth understanding. Once you see it in action, then you can recognize all of the value which comes from this tiny config file. Also, I hope the rest of this article may present some insightful topics to bring webmasters into the light of managing a .htaccess configuration. Allow/Deny Access It is possible to recognize potential spam visitors and deny them access to your website. This can be a little extreme. However, if you know that a person or group of people have been targeting your website, there are some options to choose from. You could pick a domain referral to deny or ban visitors by IP address. order allow,deny deny from 255.0.0.0 deny from 123.45.6. allow from all Notice the 2nd IP address is missing the 4th integer. This code block will target the first IP(255.0.0.0) and every IP within the range of 123.45.6.0-255, then allow all other traffic. Prevent Directory Listing There will be times when you have an open directory that is set up to allow browsing by default. This means users can view all the files listed inside an internal directory structure, like your images folder. Some developers do not want to allow directory listing, and thankfully, the code snippet is pretty easy to remember. Options -Indexes I have seen this answer presented countless times throughout Stack Overflow and it may be one of the easiest .htaccess rules to remember. It is possible to actually create multiple .htaccess files inside each of these directories,  » Read More

Like to keep reading?

This article first appeared on hongkiat.com. If you'd like to continue this story, follow the white rabbit.

View Full Article
Laravel Vs Symfony: Answering All The Questions To Make a Better Choice

Laravel Vs Symfony: Answering All The Questions To Make a Better Choice

#Dev
How to Channel a Daily Vision into a 20-Year Photography Career

How to Channel a Daily Vision into a 20-Year Photography Career

#Silicon Valley
WordPress Punts Locally Hosted Fonts for Legacy Default Themes to 6.2 Release

WordPress Punts Locally Hosted Fonts for Legacy Default Themes to 6.2 Release

#Web Design
Fresh For Designers

Is the Dynamic Island plain stupid or the next revolutionary UX pattern?

#All

Let's talk about Design