Your Ad Here

Posted By

section31 on 07/06/08


Tagged


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

SpinZ
wizard04
basicmagic
liqweed


Apache Config Changes


 / Published in: Apache
 

  1. Removes www using a mod rewrite condition. Put this in your .htaccess file or apache config.
  2. Forces https on url.
  1. # 1. force removal of www IN URL
  2. RewriteEngine On
  3. RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
  4. RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
  5. # END force removal of www IN URL# force www IN URL
  6.  
  7. # 2. start https check
  8. RewriteEngine On
  9. RewriteCond %{SERVER_PORT} 80
  10. RewriteRule ^(.*)$ https://example.com/$1 [R,L]
  11. # end https check

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: bbnnt on August 10, 2008

this above rule will add a double slash at the end of the url (http://www.url.com => http://url.com//, http://www.url.com/somefileorsomedirectory... => http://www.url.com//somefileorsomedirectory..., etc).

this one worked better :

RewriteCond %{HTTP_HOST} ^www.url.com$ [NC]
RewriteRule ^(.*)$ http://url.com$1 [R=301,L]

You need to login to post a comment.