Welcome to WebmasterWorld Guest from 54.205.74.11

Forum Moderators: Ocean10000 & incrediBILL & phranque

URGENT HTACCESS makes too much load ? URGENT

Please what to do? When I upload my htaccess file it hangs my server.

   
7:03 am on Feb 10, 2010 (gmt 0)

5+ Year Member



Hello jdMorgan

Thanks jdmorgan for free help. I upload my htaccess to the server but when I uploaded my server starts hang likes too much load on it. I tires it two to three times. All the time same hanging but when I replace the HTACCESS file with my previous then server is working good

My HTACCESS file which stucks server is: A text in bold is changed by me in this file. Can you please tell me what causing this error
================================================================================================================
#prevent directory listing
#Options -Indexes

# enable expirations
ExpiresActive On
<FilesMatch "\.(png|jpg|css|js|gif)$">
Header set Cache-Control "max-age=4419200, public"
</FilesMatch>

#error documents
ErrorDocument 400 /errors/?e=badrequest
ErrorDocument 401 /errors/?e=authreqd
ErrorDocument 403 /errors/?e=forbid
ErrorDocument 404 /errors/?e=notfound
ErrorDocument 500 /errors/?e=serverr

#URL rewrite
Options +FollowSymLinks
RewriteEngine On


#Redirect links
RewriteRule ^([^\ ]*)\ (.*)$ $1-$2 [E=rspace:yes,N]

#For redirect a spaces invovled link to hyphens involved links
RewriteCond %{ENV:rspace} ^yes$
RewriteRule ^(.*)$ http://www.example.com.au/$1? [R=301,L]



#RewriteBase /~whatsope/public_html

#paginate/filter: example.com.au/search/STATE/view/page/status/city|category|tag|postcode|distance/key+words/char
#RewriteRule ^search/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/ /?q=$6&f=$1|$5&pg=$3&ltype=$2&status=$4&char=$7
#RewriteRule ^search/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*) /?q=$6&f=$1|$5&pg=$3&ltype=$2&status=$4&char=$7
#RewriteRule ^search/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/ /?q=$6&f=$1|$5&pg=$3&ltype=$2&status=$4
#RewriteRule ^search/(.*)/(.*)/(.*)/(.*)/(.*)/(.*) /?q=$6&f=$1|$5&pg=$3&ltype=$2&status=$4

#paginate (no filters or state): example.com.au/search/view/status/key+words/page
RewriteRule ^search/(.*)/(.*)/(.*)/(.*)/ /?ltype=$1&status=$2&q=$3&pg=$4
RewriteRule ^search/(.*)/(.*)/(.*)/(.*) /?ltype=$1&status=$2&q=$3&pg=$4
RewriteRule ^search/(.*)/(.*)/(.*)/ /?ltype=$1&status=$2&q=$3
RewriteRule ^search/(.*)/(.*)/(.*) /?ltype=$1&status=$2&q=$3

#browse/filter: example.com.au/browse/STATE/city/Category/view/tag|postcode|distance/page/sort/
#RewriteRule ^search/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/ /?q=$5&f=$1|$2|$3|$5&p=$6&s=$7&ltype=$4

#venue listing: example.com.au/venues/STATE/city/VenueId/Venue+Name
RewriteRule ^venues/(.*)/(.*)/(.*)/(.*)/ /venues.php?vID=$3
RewriteRule ^venues/(.*)/(.*)/(.*)/(.*) /venues.php?vID=$4
RewriteRule ^venues/(.*)/(.*)/(.*)/ /venues.php?vID=$4
RewriteRule ^venues/(.*)/(.*)/(.*) /venues.php?vID=$4

RewriteRule ^venue/(.*)/(.*)/ /venues.php?vID=$1&q=$2
RewriteRule ^venue/(.*)/(.*) /venues.php?vID=$1&q=$2

#nearby: example.com.au/near/VenueId/Venue+Name
RewriteRule ^near/(.*)/(.*)/ /?ltype=map&near=$1&nearVenue=$2
RewriteRule ^near/(.*)/(.*) /?ltype=map&near=$1&nearVenue=$2
RewriteRule ^near/(.*) /?ltype=map&near=$1
RewriteRule ^near/*$ near/
RewriteRule ^near /?ltype=map

#users template: example.com.au/users/pagename
#RewriteRule ^users/(.*)/ users/$1.php
#RewriteRule ^users/(.*) users/$1.php
#RewriteRule ^users/*$ users/
#RewriteRule ^users ?

#reviews: example.com.au/reviews/STATE/city/Category
#RewriteRule ^reviews/(.*)/(.*)/(.*)/ ?f=$1|$2|$3
#RewriteRule ^reviews/(.*)/(.*)/(.*) ?f=$1|$2|$3

#events template: example.com.au/events/STATE/city/EventId/Event+Name
#RewriteRule ^events/(.*)/(.*)/(.*)/(.*)/ ?p=venue&id=$3
#RewriteRule ^events/(.*)/(.*)/(.*)/(.*) ?p=venue&id=$3

#content template: example.com.au/content/pagename
RewriteRule ^content/(.*)/ /$1.php
RewriteRule ^content/(.*) /$1.php

#prevent hotlinking, replace images with alternative image
#RewriteCond %{HTTP_REFERER} !^$
#RewriteCond %{HTTP_REFERER} !^http://(www\.)?example.com.au/.*$ [NC]
#RewriteRule \.(gif|jpg|png)$ http://www.example.com.au/denied.gif [NC]

#remove www
#RewriteCond %{HTTP_HOST} !^(www\.)?example\.com\.au [NC]
#RewriteCond %{HTTP_HOST} ^(.+)\.example\.com\.au [NC]
#RewriteRule .* http://www.example.com.au//%1 [R=301,L]

#replace spaces, + and %20 with hyphen



#block bad bots / site rippers
RewriteCond %{HTTP_USER_AGENT} ^BlackWidow [OR]
RewriteCond %{HTTP_USER_AGENT} ^Bot\ mailto:craftbot@yahoo.com [OR]
<snip>
RewriteCond %{HTTP_USER_AGENT} ^Xaldon\ WebSpider [OR]
RewriteCond %{HTTP_USER_AGENT} ^Zeus
RewriteRule ^.* - [F,L]


#prevent viewing of htaccess files
<Files .htaccess>
order allow,deny
deny from all
</Files>
================================================================================================================




And my previous HTACCESS file which is on server is:
================================================================================================================
#prevent directory listing
#Options -Indexes

# enable expirations
ExpiresActive On
<FilesMatch "\.(png|jpg|css|js|gif)$">
Header set Cache-Control "max-age=4419200, public"
</FilesMatch>

#error documents
ErrorDocument 400 /errors/?e=badrequest
ErrorDocument 401 /errors/?e=authreqd
ErrorDocument 403 /errors/?e=forbid
ErrorDocument 404 /errors/?e=notfound
ErrorDocument 500 /errors/?e=serverr

#URL rewrite
Options +FollowSymLinks
RewriteEngine On


#RewriteBase /~whatsope/public_html

#paginate/filter: example.com.au/search/STATE/view/page/status/city|category|tag|postcode|distance/key+words/char
#RewriteRule ^search/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/ /?q=$6&f=$1|$5&pg=$3&ltype=$2&status=$4&char=$7
#RewriteRule ^search/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*) /?q=$6&f=$1|$5&pg=$3&ltype=$2&status=$4&char=$7
#RewriteRule ^search/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/ /?q=$6&f=$1|$5&pg=$3&ltype=$2&status=$4
#RewriteRule ^search/(.*)/(.*)/(.*)/(.*)/(.*)/(.*) /?q=$6&f=$1|$5&pg=$3&ltype=$2&status=$4

#paginate (no filters or state): example.com.au/search/view/status/key+words/page
RewriteRule ^search/(.*)/(.*)/(.*)/(.*)/ /?ltype=$1&status=$2&q=$3&pg=$4
RewriteRule ^search/(.*)/(.*)/(.*)/(.*) /?ltype=$1&status=$2&q=$3&pg=$4
RewriteRule ^search/(.*)/(.*)/(.*)/ /?ltype=$1&status=$2&q=$3
RewriteRule ^search/(.*)/(.*)/(.*) /?ltype=$1&status=$2&q=$3

#browse/filter: example.com.au/browse/STATE/city/Category/view/tag|postcode|distance/page/sort/
#RewriteRule ^search/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/ /?q=$5&f=$1|$2|$3|$5&p=$6&s=$7&ltype=$4

#venue listing: example.com.au/venues/STATE/city/VenueId/Venue+Name
RewriteRule ^venues/(.*)/(.*)/(.*)/(.*)/ /venues.php?vID=$3
RewriteRule ^venues/(.*)/(.*)/(.*)/(.*) /venues.php?vID=$4
RewriteRule ^venues/(.*)/(.*)/(.*)/ /venues.php?vID=$4
RewriteRule ^venues/(.*)/(.*)/(.*) /venues.php?vID=$4

RewriteRule ^venue/(.*)/(.*)/ /venues.php?vID=$1&q=$2
RewriteRule ^venue/(.*)/(.*) /venues.php?vID=$1&q=$2

#nearby: example.com.au/near/VenueId/Venue+Name
RewriteRule ^near/(.*)/(.*)/ /?ltype=map&near=$1&nearVenue=$2
RewriteRule ^near/(.*)/(.*) /?ltype=map&near=$1&nearVenue=$2
RewriteRule ^near/(.*) /?ltype=map&near=$1
RewriteRule ^near/*$ near/
RewriteRule ^near /?ltype=map

#users template: example.com.au/users/pagename
#RewriteRule ^users/(.*)/ users/$1.php
#RewriteRule ^users/(.*) users/$1.php
#RewriteRule ^users/*$ users/
#RewriteRule ^users ?

#reviews: example.com.au/reviews/STATE/city/Category
#RewriteRule ^reviews/(.*)/(.*)/(.*)/ ?f=$1|$2|$3
#RewriteRule ^reviews/(.*)/(.*)/(.*) ?f=$1|$2|$3

#events template: example.com.au/events/STATE/city/EventId/Event+Name
#RewriteRule ^events/(.*)/(.*)/(.*)/(.*)/ ?p=venue&id=$3
#RewriteRule ^events/(.*)/(.*)/(.*)/(.*) ?p=venue&id=$3

#content template: example.com.au/content/pagename
RewriteRule ^content/(.*)/ /$1.php
RewriteRule ^content/(.*) /$1.php

#prevent hotlinking, replace images with alternative image
#RewriteCond %{HTTP_REFERER} !^$
#RewriteCond %{HTTP_REFERER} !^http://(www\.)?example.com.au/.*$ [NC]
#RewriteRule \.(gif|jpg|png)$ http://www.example.com.au/denied.gif [NC]

#remove www
#RewriteCond %{HTTP_HOST} !^(www\.)?example\.com\.au [NC]
#RewriteCond %{HTTP_HOST} ^(.+)\.example\.com\.au [NC]
#RewriteRule .* http://www.example.com.au//%1 [R=301,L]

#replace spaces, + and %20 with hyphen



#block bad bots / site rippers
RewriteCond %{HTTP_USER_AGENT} ^BlackWidow [OR]
RewriteCond %{HTTP_USER_AGENT} ^Bot\ mailto:craftbot@yahoo.com [OR]
<snip>
RewriteCond %{HTTP_USER_AGENT} ^Xaldon\ WebSpider [OR]
RewriteCond %{HTTP_USER_AGENT} ^Zeus
RewriteRule ^.* - [F,L]


#prevent viewing of htaccess files
<Files .htaccess>
order allow,deny
deny from all
</Files>
================================================================================================================

[edited by: jdMorgan at 1:00 pm (utc) on Feb 10, 2010]
[edit reason] example.com.au, snipped long bad-bot list [/edit]

12:45 pm on Feb 10, 2010 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Never, ever, use multiple ".*" patterns in your rules... Or you pay this price.

If you use multiple-".*" patterns, each rule may have to be evaluated dozens, hundreds or even thousands of time to determine a match. While ".*" is an "easy" pattern to understand, it can also cause extremely-inefficient processing because it matches anything, everything, or nothing.

Use a more-specific pattern.

Further, you have failed to end-anchor the patterns or to put an [L] flag on most of the rules above. This will also affect performance.

I suggest that you fix the rules like this example:
Replace
 RewriteRule ^search/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/ /?q=$6&f=$1|$5&pg=$3&ltype=$2&status=$4&char=$7 

with
 RewriteRule ^search/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)[b]/$[/b] /?q=$6&f=$1|$5&pg=$3&ltype=$2&status=$4&char=$7 [b][L][/b] 

for an immediate --and likely dramatic-- performance improvement.

Also, do be sure that you site links only to hyphenated links; Otherwise, you're going to redirect many, many times in the process of loading a page...

The hyphen rule can be further improved if your old URLs have multiple spaces. Let's fix the other problems first.

Jim

[edited by: jdMorgan at 1:02 pm (utc) on Feb 10, 2010]

12:56 pm on Feb 10, 2010 (gmt 0)

WebmasterWorld Senior Member wilderness is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



([^/]+)/([^/]+)/


Jim, or another,
Are these sub-directories?
In the quote I've provided two?
In the example that Jim corrected, seven?

Thanks in advance.

Don
1:03 pm on Feb 10, 2010 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



These are "virtual subdirectories" used to put the query parameters into an "SEO friendly" URL. They do not physically exist.

Jim
 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month