3

First of all, I consider myself more a programmer than a servers guy. I have a website where I receive about 3,000 visits per day, which I think is a lot less than the max capacity for a dedicated server.

However, I've noticed that the connection to the website is pretty slow, e.g., to load images, to connect to it via SSH, etc.

I configured .httaccess recently to avoid hotlinking to images in my server (i.e. .jpg, .gif and .png), and I was wondering if that could be slowing down my website.

This is the configuration that I have:

# BEGIN WordPress

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://www.mysite.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.mysite.com$ [NC]
RewriteRule .*\.(jpg|jpeg|gif|png|bmp|swf)$ http://www.google.com/ [R,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

I found some code to do that in google, and I just copied to .htacces since I'm not an expert in apache. It works, but I don't know if that is the best way to do it.

How can I see if that is the reason why the server is slow? Are there any tools to monitor it? What would you do guys?

Thanks in advance!

David Robles
  • 131
  • 2

1 Answers1

6
  • Is .htaccess slowing down my server? Sure, probably, but maybe not enough that you care. If you allow .htaccess files to override the server configuration, Apache needs to search all directories in a URL path for a .htaccess file (e.g., if you access /foo/bar/baz/index.html, then Apache needs to look for .../foo/bar/baz/.htaccess, .../foo/bar/.htaccess, .../foo/.htaccess, and .../.htaccess, where "..." is that path to your DocumentRoot). This requires a finite amount of time which you can avoid if you put all your configuration in the server config files and set AllowOverride None.

  • Are there any tools to monitor server performance? There are a number of tools you can use to assess the performance of your server. Apache ships with the ab tool ("Apache Bench"); see the man page for details. Another popular solution is Apache jmeter. You would want to run tests with .htaccess files disabled and enabled and see if there's a noticeable difference.

  • What would you do guys? If I had control over the server I would set AllowOverride None and put the configuration inside of an appropriate <Directory> or <Location> directive.

larsks
  • 41,276
  • 13
  • 117
  • 170
  • Since I have complete control of the server, I will probably put the configuration in the server config files. Thanks! – David Robles Dec 14 '09 at 00:55