background preloader


Facebook Twitter

Stupid htaccess Tricks. Welcome to Perishable Press!

Stupid htaccess Tricks

This article, Stupid htaccess Tricks, covers just about every htaccess “trick” in the book, and is easily the site’s most popular offering. In addition to this htaccess article, you may also want to explore the rapidly expanding htaccess tag archive. Along with all things htaccess, Perishable Press also focuses on (X)HTML, CSS, PHP, JavaScript, security, and just about every other aspect of web design, blogging, and online success. If these topics are of interest to you, I encourage you to subscribe to Perishable Press for a periodic dose of online enlightenment ;) General Information [ ^ ] .htaccess Definition 1 ^ Apache server software provides distributed (i.e., directory-level) configuration via Hypertext Access files.

Commenting .htaccess Code ^ Comments are essential to maintaining control over any involved portion of code. Important Notes for .htaccess Noobs ^ As a configuration file, .htaccess is very powerful. Performance Issues ^ [S=x] [E=variable:value] Beginners guide to .htaccess file with examples. Htaccess file allow us to make configuration changes on a per-directory basis. htaccess file works in Apache Web Server on both Linux/Unix and Windows operating system.

Beginners guide to .htaccess file with examples

This article has some basic .htaccess examples, such as htaccess redirect, to get you started with .htaccess right away. Just copy and paste the lines mentioned in this post below, with or without any modification, in your .htaccess file and it should work. There are several things that developers, site owners and webmasters can do by using .htaccess file. Let’s look at some of them: Prevent directory browsingRedirect visitors from one page or directory to anotherPassword protection for directoriesChange the default index page of a directoryPrevent hot-linking of images from your website. Behind the Scenes with Apache's .htaccess - Brainstorms and Raves. Behind the Scenes with Apache’s .htaccess Although I’m a designer and not a programmer or server-side specialist, for a few years I’ve used Apache’s .htaccess to a limited degree for clients' websites, primarily for simple URL redirects and setting up custom error pages.

Behind the Scenes with Apache's .htaccess - Brainstorms and Raves

Now that I can use Apache’s .htaccess for my own websites, I’ve been immersed in learning more about how to use this powerful tool conservatively but effectively to redirect URLs and to combat spammers and bad bots. Today’s post provides links to some of the online sources that I’ve found especially helpful.

First, A Word of Warning Keep in mind that one little typo or incorrect rule within an .htaccess file can cause an internal server error and take your entire website offline. In addition, many caution those new to .htaccess about not getting too carried away and ending up creating excessively big .htaccess files. Regarding combating bad bots and spammers, .htaccess is one of several tools and approaches that I use. Dynamic Drive: .htaccess password generator.

Online Tools: .htaccess Password Generator Use this tool to generate all the necessary codes needed to password protect a directory or selects files within it on your site via .htaccess.

Dynamic Drive: .htaccess password generator

It encrypts the desired passwords, then outputs the corresponding codes to put inside your .htaccess and .htpasswd files. Example: Click here. (Username: user Password: test) Frequently Asked Questions Q: For 2) above, what should I enter as the path? Q: For 2) above, how can I find out my server path? Q: For 3) above, what should I enter, if anything? Q: I've uploaded my .htaccess and .htpasswd files to the correct locations, but when I try and enter my username/password to enter the protected area, it still wouldn't let me in!

AuthUserFile /home/mysite/.htpasswd As mentioned, in Linux you can type "pwd" in telnet/SSH to find out your server's root directory (ie: /home/mysite). Q: How come after I've uploaded my .htaccess file via FTP, I can no longer see it in FTP?