4 ms·
The very title of this blog post tells me that it is bad advice. What you should do is disable .htaccess and put all configuration in the VirtualHost configura
by olefoo 17y ago
The very title of this blog post tells me that it is bad advice.
What you should do is disable .htaccess and put all configuration in the VirtualHost configuration file.
Why?
Because when you have AllowOverride ON the webserver has to look for the .htaccess file and parse it if it exists for each and every request.
So if you lard up your .htaccess with 300 lines of rewrite rules and document handlers and so on, that has to be parsed for every page the server hands out. Which is one of the reasons some ignorant people think apache is slow.
- Hexstream 17y agoI'm guessing having configuration centralized is also easier to manage and a bit more secure. As for performance, doesn't/couldn't Apache parse and cache a .htaccess file just once, and then only check the timestamp on subsequent requests?
- olefoo 17y agoIt still has to stat the file every time. And it's worse than you think. A path with four elements like http://example.com/one/two/three/four/thing.php http://example.com/one/two/three/four/thing.php requires that 5 directories be checked for an .htaccess file. Which means apache has to keep track of if there was .htaccess file in that directory the last time it looked for 5 directories, and for each of those whether the timestamp or the size has changed. I'd have to look at the code to see if it caches information about override files but I don't think it does.
- shabda 17y agoYour advice is untenable as .htaccess are used mostly with PHP based shared hosting(as newer non php frameworks mosty have smart urls by default), where allowing everyone to dump their Rewrite rules in httpd.conf is not possible.
- olefoo 17y agoThis is why people who are building professional websites don't put them on $4.95 a month shared hosting plans.