Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

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$  $1.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=$1 [L,NC]

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

share|improve this question
add comment

2 Answers 2

up vote 6 down vote accepted

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$ $1.php [L,NC]
RewriteRule ^patients/findadoctor/([a-z])\.html$ findadoctor.php?id=$1 [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=$1 [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=$1 [L,NC]
share|improve this answer
    
Thank you it work nice but have other question if i have to reduce 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=$1 [L,NC] –  Parimal May 1 '13 at 10:28
    
I updated my answer. (If this answers your query then you can mark the answer as "accepted".) –  w3d May 1 '13 at 16:33
add comment

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.
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.