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'm working with a client on an e-commerce website. I implemented clean URLs using .htaccess. I also used .htaccess to solve canonical issues such as redirecting www to non-www and removing index.php from the URL.

The website recently began to slow down dramatically, sometimes not even loading. The site is hosted on GoDaddy, and when the client called GoDaddy they told him it was the .htaccess file slowing down the website. I find this highly unlikely because of my past experiences, but I'm not 100% sure. My thinking is that the client's website is most likely on a shared server with a busy neighborhood, thus slowing down the site. It's not always slow, but rather sporadic throughout the day, loading fast at some points and slow at other points in time.

Can the .htaccess file slow down a website to a crawl? If so, are there better ways to solve these problems with different rewrite rules and such?

Here is what the actual .htaccess file looks like:

    Options +FollowSymlinks
    RewriteEngine   On
    RewriteBase /
    RewriteCond %{HTTP_HOST} ^www.example.net [NC]
    RewriteRule ^(.*)$ http://example.net/$1 [L,R=301]
    RewriteRule ^products/([0-9a-zA-Z\_\-]*)\.htm([l]?)$ index.php p=product&product_code=$1 [L]
    RewriteRule ^catalog/([0-9a-zA-Z\_\-]*)\.htm([l]?)$ index.php p=catalog&catalog_code=$1 [L]
    RewriteRule ^pages/([0-9a-zA-Z\_\-]*)\.htm([l]?)$   index.php?p=page&page_id=$1 [L]
    RewriteRule ^index\.htm([l]?)$  index.php?p=home [L]
    RewriteRule ^site_map\.htm([l]?)$   index.php?p=site_map [L]
    RewriteCond      %{QUERY_STRING}    ^p=home$
    RewriteRule      (.*)               ?     [R=permanent]

I'm a .htaccess and regex novice, so any pointed out mistakes would also help.

share|improve this question
    
You may be better off with server fault for this one. Have you checked to see if the site has been compromised by malware? –  toomanyairmiles Apr 3 '12 at 22:59
4  
similar to serverfault.com/q/137738/95089 –  Refineo Apr 3 '12 at 23:12
1  
    
it will, but you will hardly notice the changes –  Eric Yin Apr 4 '12 at 19:36
add comment

2 Answers

Can the .htaccess file slow down a website to a crawl? If so, are there better ways to solve these problems with different rewrite rules and such?

AllowOverride all impacts server performance as Apache must check for .htaccess files and parse directives with each request - if possible, keep all directives in the VirtualHost configuration for your site or enable .htaccess overrides only for the directories which need them.

- Everything You Ever Wanted to Know about Mod_Rewrite Rules but Were Afraid to Ask

You will probably not have access to the VirtualHost configuration for your GoDaddy shared hosting account and, given that there are probably hundreds or thousands of other sites on the same server (and you've observed that performance fluctuates) it's not just an issue with your scripts or rules.

share|improve this answer
add comment

I guess technically it would slow it down a bit, as in order to follow the rules the server would have to first process them. However I don't think it would slow the server to a crawl, and probably wouldn't be very noticeable at all.

I would hazard a guess and say it is caused by the shared hosting at GoDaddy. I previously had hosting with them and found them to be very slow at times as well. The fact that it is faster at times, and slower at others, suggests this as well.

share|improve this answer
add comment

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.