Mobile app version of vmapp.org
Login or Join
Murray155

: 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 my htaccess file...... RewriteCond

@Murray155

Posted in: #Htaccess #Php #WebCrawlers

here is my htaccess file......

RewriteCond %{REQUEST_URI} ^/patients/billing/FAQ_billing.html$ [OR]
RewriteCond %{REQUEST_URI} ^/patients/billing/getintouch.html$
RewriteRule ^patients/billing/(.*).html$ .php [L,NC]

RewriteCond %{REQUEST_URI} ^/patients/findadoctor/a.html$ [OR]
RewriteCond %{REQUEST_URI} ^/patients/findadoctor/b.html$ [OR]
RewriteCond %{REQUEST_URI} ^/patients/findadoctor/c.html$ [OR]
RewriteCond %{REQUEST_URI} ^/patients/findadoctor/d.html$ [OR]
RewriteCond %{REQUEST_URI} ^/patients/findadoctor/e.html$ [OR]
RewriteCond %{REQUEST_URI} ^/patients/findadoctor/f.html$ [OR]
RewriteCond %{REQUEST_URI} ^/patients/findadoctor/g.html$ [OR]
RewriteCond %{REQUEST_URI} ^/patients/findadoctor/h.html$ [OR]
RewriteCond %{REQUEST_URI} ^/patients/findadoctor/i.html$ [OR]
RewriteCond %{REQUEST_URI} ^/patients/findadoctor/j.html$ [OR]
RewriteCond %{REQUEST_URI} ^/patients/findadoctor/k.html$ [OR]
RewriteCond %{REQUEST_URI} ^/patients/findadoctor/l.html$ [OR]
RewriteCond %{REQUEST_URI} ^/patients/findadoctor/m.html$ [OR]
RewriteCond %{REQUEST_URI} ^/patients/findadoctor/n.html$ [OR]
RewriteCond %{REQUEST_URI} ^/patients/findadoctor/o.html$ [OR]
RewriteCond %{REQUEST_URI} ^/patients/findadoctor/p.html$ [OR]
RewriteCond %{REQUEST_URI} ^/patients/findadoctor/q.html$ [OR]
RewriteCond %{REQUEST_URI} ^/patients/findadoctor/r.html$ [OR]
RewriteCond %{REQUEST_URI} ^/patients/findadoctor/s.html$ [OR]
RewriteCond %{REQUEST_URI} ^/patients/findadoctor/t.html$ [OR]
RewriteCond %{REQUEST_URI} ^/patients/findadoctor/u.html$ [OR]
RewriteCond %{REQUEST_URI} ^/patients/findadoctor/v.html$ [OR]
RewriteCond %{REQUEST_URI} ^/patients/findadoctor/w.html$ [OR]
RewriteCond %{REQUEST_URI} ^/patients/findadoctor/x.html$ [OR]
RewriteCond %{REQUEST_URI} ^/patients/findadoctor/y.html$ [OR]
RewriteCond %{REQUEST_URI} ^/patients/findadoctor/z.html$
RewriteRule ^patients/findadoctor/(.*).html$ findadoctor.php?id= [L,NC]


like that there is lots of rules around 250 line please help me...

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Murray155

2 Comments

Sorted by latest first Latest Oldest Best

 

@Cofer257

The htaccess does, by definition, slow down your site because the server must check every folder for the file - e.g. in your case the folders /patients/findadoctor/, /patients/ and the root folder. It is more efficient to write those rules in the server config itself, then set AllowOverride None, which will stop Apache looking for htaccess files. If you are using shared hosting you will unlikely be able to do this. Also it requires restarting the server every time you make a change to the config.

However, the performance in the majority of cases should not be a huge problem. First you should check that it is the htaccess file that's slowing down the site:


If the server responds immediately but the page takes a while to load, it would be a problem with the front end (HTML, CSS, Javascript). Check the Network tab in Chrome Dev Tools or Firebug, it will show timings.
If you temporarily remove all the htaccess rules and load the rewritten URL directly (e.g. findadoctor.php?id=a) and it still takes a long time to load, then it's a problem with the PHP code somewhere.

10% popularity Vote Up Vote Down


 

@Ann8826881

This is no doubt dependent on your remaining 200+ lines, but what you have posted so far would seem to be reducible to just 2 lines:

RewriteRule ^patients/billing/(FAQ_billing|getintouch).html$ .php [L,NC]
RewriteRule ^patients/findadoctor/([a-z]).html$ findadoctor.php?id= [L,NC]


This shouldn't be reducing your site to a crawl.

As mentioned in comments, if you have something like the following, then it becomes difficult to reduce this further if you are only wanting to rewrite specific URLs.

RewriteCond %{REQUEST_URI} ^/patients/findadoctor/paediatriccardiacanaesthesiology.html$ [OR]
RewriteCond %{REQUEST_URI} ^/patients/findadoctor/paediatriccardiovascularthoracicsurgery.html$ [OR]
RewriteCond %{REQUEST_URI} ^/patients/findadoctor/bonemarrowtransplant.html$ [OR]
RewriteCond %{REQUEST_URI} ^/patients/findadoctor/kidneytransplant.html$ [OR]
RewriteCond %{REQUEST_URI} ^/patients/findadoctor/cardiacanaesthesiology.html$
RewriteRule ^patients/findadoctor/(.*).html$ subcategorydoctor.php?id= [L,NC]


However, if you can find a pattern, (eg. a-z and minimum 14 chars in length) then you could reduce this to something like:

RewriteRule ^patients/findadoctor/([a-z]{14,}).html$ subcategorydoctor.php?id= [L,NC]

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme