Posted By

yanek1988 on 10/15/11


Tagged

htaccess


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

localsearchguy
mrtess


.htaccess hacks


 / Published in: lighttpd
 

  1. === Blacklist undesired users and bots ip address
  2.  
  3. <Limit GET POST PUT>
  4. order allow,deny
  5. allow from all
  6. deny from 123.456.789
  7. deny from 93.121.788
  8. deny from 223.956.789
  9. deny from 128.456.780
  10. </LIMIT>
  11.  
  12. === Redirect www to non www or vice versa
  13.  
  14. RewriteEngine On
  15. RewriteBase /
  16. RewriteCond %{HTTP_HOST} ^www.yourblogname.com [NC]
  17. RewriteRule ^(.*)$ http://yourblogname.com/$1 [L,R=301]
  18.  
  19. RewriteEngine On
  20. RewriteBase /
  21. RewriteCond %{HTTP_HOST} ^yourblogname.com [NC]
  22. RewriteRule ^(.*)$ http://www.yourblogname.com/$1 [L,R=301]
  23.  
  24. === SEO Friendly 301 Redirects
  25.  
  26. Redirect 301 /abc/file.html http://www.yourblogname.com/def/file.html
  27.  
  28. === How to: Deny comment posting to no referrer requests
  29.  
  30. RewriteEngine On
  31. RewriteCond %{REQUEST_METHOD} POST
  32. RewriteCond %{REQUEST_URI} .wp-comments-post\.php*
  33. RewriteCond %{HTTP_REFERER} !.*yourblog.com.* [OR]
  34. RewriteCond %{HTTP_USER_AGENT} ^$
  35. RewriteRule (.*) ^http://%{REMOTE_ADDR}/$ [R=301,L]
  36.  
  37. === Customized HTTP 404 error page
  38.  
  39. ErrorDocument 401 /err/401.php
  40. ErrorDocument 403 /err/403.php
  41. ErrorDocument 404 /err/404.php
  42. ErrorDocument 500 /err/500.php

Report this snippet  

You need to login to post a comment.