: Can .htaccess slow down a site? 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
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 ^(.*)$ example.net/ [L,R=301]
RewriteRule ^products/([0-9a-zA-Z_-]*).htm([l]?)$ index.php p=product&product_code= [L]
RewriteRule ^catalog/([0-9a-zA-Z_-]*).htm([l]?)$ index.php p=catalog&catalog_code= [L]
RewriteRule ^pages/([0-9a-zA-Z_-]*).htm([l]?)$ index.php?p=page&page_id= [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.
More posts by @Jamie184
3 Comments
Sorted by latest first Latest Oldest Best
You can try L2MP Stack (http://l2mp.ml) It support htaccess and Litespeed 6x Faster than Apache
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.
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.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.