educational

Real World .htaccess Files

For the newbie webmaster, few things are as confusing as .htaccess files; yet, few things can provide as much benefit to websites using this web server instruction file. And, despite the surface confusion, using .htaccess files actually is quite simple.

.htaccess files can be used for access control, error redirection and more. To get you started with a real world example, let's look at server errors, custom error pages, redirection and htaccess:

Error Redirects
Some webpage requests result in server errors. These errors usually result in the display of a stock server-error page – something that nearly every surfer has encountered, probably more often than they would like. Different websites need to handle errors – and the pages they display in response to them – in different ways. They also should account for the reasons that errors are being generated and consider how best to deal with the situation.

For example, the most frequently encountered error page is the "404" or "Page not found" error. 404s typically result from syntax errors in the webpage's source code (meaning the user either misspelled the file name or used an incorrect path to point to it), or because web pages point to renamed, replaced or removed pages and files. Such errors typically are the fault of the webmaster, who either did not physically check (by manually clicking) every link on his or her website or failed to update website links to reflect changes in the linked files. 404s also are generated by curious surfers and "monkey boys" guessing their way around your free gallery files looking for the next TGP gallery in a series, for example, or even by folks trying to "guess" their way into your members area.

Regardless of the reason why a 404 is generated, dealing with the event by rerouting the traffic or displaying a custom error page, rather than ignoring it by simply displaying the stock server page, should be of prime concern to website owners – and the type of website should determine the type of response. Some operators sell this traffic outright or send it to sponsors – a potentially wise move, especially for traffic-pump and free-site operators. For these webmasters, 404 traffic is often seen as "garbage" traffic and disposed of quickly.

Pay site operators, on the other hand, should realize that a 404 often is generated when a surfer clicks a link and does not receive the page or file that he was expecting – something that may be the webmaster's fault. Rather than disappointing a paying customer, it's better to have a custom 404 page with links to your home page, site map and contact info. By helping this surfer, rather than sending him away or "ignoring" his or her needs, you build a better relationship, which may transform disappointment into longer retention rates.

Likewise, how you handle your "401" or "Authorization Required" errors can dramatically impact your profitability. 401s typically are generated by surfers after three failed attempts at entering a valid username and password combination while trying to gain access to a password-protected directory, such as /members/.

Once again, the type of website should determine the response. For example, a TGP, where 401s are being generated by "monkey boys" trying to hack into the admin system, should treat these errors differently than a paysite, which needs to ensure that legitimate customers have no difficulties in accessing content that they have paid for. In this case, a "help" page with customer service contact info should be displayed, offering an online form that surfers can fill out, allowing them to provide your customer service staff with the username / password combo that they were attempting to use.

There are other server error codes, some of which are not frequently encountered. You can find a list of codes and their meanings here. You can use this list to fine-tune your error traffic flow, but be careful that you're not causing problems for yourself or your website's visitors.

A Sample .htaccess File
While .htaccess files can have many specialized elements and perform tasks such as preventing bandwidth thieves from hotlinking your images and rewriting long, dynamic URLs into easily remembered short-form URLs, the "real world" example I want to show you contains only one line:

[CODE]ErrorDocument 404 http://www.domain.com/404-page.html[/CODE]

Copy the above line to a blank text document. Change the URL to point to your custom 404 error page, or to the destination you wish to send this traffic, such as your home page, hub, or sponsor, then save this page as ".htaccess" and upload it to your website's root directory. It's that simple...

You can add 401 redirection by adding an additional line:

[CODE]ErrorDocument 401 http://www.domain.com/401-page.html[/CODE]
[CODE]ErrorDocument 404 http://www.domain.com/404-page.html[/CODE]

You can also begin geo-targeting your traffic by adding a blank line under the code above, then pasting the redirect code from my previous article, "Real World Redirection" below it.

There's much more to the power of using .htaccess files; search our article archives for more examples and take control of your traffic today.

Copyright © 2024 Adnet Media. All Rights Reserved. XBIZ is a trademark of Adnet Media.
Reproduction in whole or in part in any form or medium without express written permission is prohibited.

More Articles

profile

'Traffic Captain' Andy Wullmer Braves the High Seas as Spirited Exec

Wullmer networked and hobnobbed, gaining expertise in everything from ecommerce to SEO and traffic, making connections and over time rising through the ranks of several companies to become CEO of the mobile business arm of TrafficPartner.

Alejandro Freixes ·
opinion

To Cloud or Not to Cloud, That Is the Question

Let’s be honest. It just sounds way cooler to say your business is “in the cloud,” right? Buzzwords make everything sound chic and relevant. In fact, someone uninformed might even assume that any hosting that is not in the cloud is inferior. So what’s the truth?

Brad Mitchell ·
opinion

Upcoming Visa Price Changes to Registration, Transaction Fees

Visa is updating its fee structure. Effective April 1, both the card brand’s initial nonrefundable application fee and annual renewal fee will increase from $500 to $950. Visa is also introducing a fee of 10 cents for each settled transaction, and 10 basis points — 0.1% — on the payment volume of certain merchant accounts.

Jonathan Corona ·
opinion

Unpacking the New Digital Services Act

Do you hear the word “regulation” and get nervous? When it comes to the EU’s Digital Services Act (DSA), you shouldn’t worry. If you’re complying with the most up-to-date card brand regulations, you can breathe a sigh of relief.

Cathy Beardsley ·
opinion

The Perils of Relying on ChatGPT for Legal Advice

It surprised me how many people admitted that they had used ChatGPT or similar services either to draft legal documents or to provide legal advice. “Surprised” is probably an understatement of my reaction to learning about this, as “horrified” more accurately describes my emotional response.

Corey D. Silverstein ·
profile

WIA Profile: Holly Randall

If you’re one of the many regular listeners to Holly Randall’s celebrated podcast, you are already familiar with her charming intro spiel: “Hi, I’m Holly Randall and welcome to my podcast, ‘Holly Randall Unfiltered.’ This is the show about sex, the adult industry and the people in it.

Women In Adult ·
trends

What's Hot Now: Leading Content Players on Trending Genres, Monetization Strategies

The juggernaut creator economy hurtles along, fueled by ever-ascendant demand for personality-based authenticity and intimacy — yet any reports of the demise of the traditional paysite are greatly exaggerated.

Alejandro Freixes ·
opinion

An Ethical Approach to Global Tech Staffing

One thing my 24-year career as a technologist working to support the online adult entertainment industry has taught me about is the power of global staffing. Without a doubt, I have achieved significantly more business success as a direct result of hiring abroad.

Brad Mitchell ·
opinion

Finding the Right Payment Partner

Whenever I am talking with businesses that are just getting started, one particular question comes up a lot: “How do I get a merchant account?” It’s a simple question, but it has a complicated answer.

Jonathan Corona ·
opinion

The Taxman Cometh for Every Business

February may be the month of romance, but it is also a time when we need to think about something that inspires very little love: taxes. April is not far away, and the taxman is always waiting. This year, federal and most state income taxes are due Monday, April 15.

Cathy Beardsley ·
Show More