Posted By

ryarwood on 07/08/10


Tagged

htaccess apache


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

mgerdt
tre


Some Assorted .htaccess examples


 / Published in: Apache
 

Few useful HTACCESS examples.

  1. ##############################################
  2. # NON WWW TO WWW
  3. ##############################################
  4.  
  5. Options +FollowSymLinks
  6. RewriteEngine On
  7. RewriteBase /
  8. RewriteCond %{REQUEST_URI} !^/robots\.txt$
  9. RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
  10. RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
  11.  
  12.  
  13. ##############################################
  14. # DIRECTORY OR FILE
  15. ##############################################
  16.  
  17. Redirect 301 /directory http://www.pcrf-kids.org/newdirectory/
  18.  
  19.  
  20. ##############################################
  21. # HELP DEAL WITH URL STRINGS
  22. ##############################################
  23.  
  24. RewriteRule ^lyonapartment/services(.*) http://www.lyoncommunities.com/about-us? [R=301,L]
  25.  
  26.  
  27. ##############################################
  28. # NEW DOMAIN
  29. ##############################################
  30.  
  31. RewriteCond %{HTTP_HOST} ^lyonautumnchase.com$ [OR]
  32. RewriteCond %{HTTP_HOST} ^www.lyonautumnchase.com$
  33. RewriteRule ^(.*)$ http://www.lyoncommunities.com/communities/welcome/autumn-chase [R=301,L]

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: jirirybar on November 11, 2010

redirects to www.example.com/www

Simply rewrite the last line to: RewriteRule ^(.*)$ http://www.example.com/ [R=301,L]

Cheers and thanks for sharing!

You need to login to post a comment.