Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I've been told that .htaccess should be avoided when possible, as it reduces the server performance and new servers disables it or just don't implement it anymore.

I don't know how true this is, but if so I wish to find an alternative to rewrite my URLs and would thank if someone could help me.

PS: What I use it for is just to convert URLs from myexample.com/page.php?lang=LANG to myexample.com/LANG/page

share|improve this question
1  
"new servers disables it or just don't implement it anymore" isn't true at all. It's turned on by default for the majority of shared hosting providers and, unless you request it, it is rarely turned off by default when the server is created. –  John Conde Oct 17 '11 at 15:17

1 Answer 1

up vote 10 down vote accepted

I've been told that .htaccess should be avoided when possible, as it reduces the server performance and new servers disables it or just don't implement it anymore.

The part about compatibility is absolutely not true; the part about performance is kinda true but probably irrelevant for you.

What the person you quote was probably talking about is that it's faster to put Apache rules into the central configuration instead of .htaccess files: The former are loaded once into the Apache process, and don't have to be looked up on every request.

However, this is not possible on shared hosting - using .htaccess files is the only option you have there.

If you have the opportunity to put configuration options into the central configuration (i.e. you have admin access to the server), and you're worried about performance, do it. But chances are this is a non-issue really. There are lots of things to optimize in a web application before it is worth looking at this.

For simple rewriting tasks on a low- to normal-traffic web site, .htaccess is still the way to go.

share|improve this answer
    
While I agree with most of this, I would not say that "For simple rewriting tasks on a low- to normal-traffic web site, .htaccess is still the way to go." If you have write access to the central Apache configuration, there is no advantage to using .htaccess files. Sure, the disadvantage may be negligible, but that's not a reason to do it. –  David Z Oct 18 '11 at 2:11
    
@David there are a few situations where .htaccess is a tad better for maintenance - namely web apps that ship with rewrite rules in .htaccess files, and update them frequently, and testing environments where apache rules are in constant flux and restarting the server every time would be a hassle. Other than that, I agree with you. (And for a WP blog with massive traffic it may be worth manually integrating each rule update into the central config.) –  Pekka 웃 Oct 18 '11 at 4:57
    
A quote from Apache's documentation is appropriate here: You should avoid using .htaccess files completely if you have access to httpd main server config file. Using .htaccess files slows down your Apache server. Any directive that you can include in a .htaccess file is better set in a Directory block, as it will have the same effect with better performance. –  Shane Madden Oct 21 '11 at 20:55

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.