Published in: Apache
- Removes www using a mod rewrite condition. Put this in your .htaccess file or apache config.
- Forces https on url.
# 1. force removal of www IN URL RewriteEngine On RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC] RewriteRule ^(.*)$ http://example.com/$1 [R=301,L] # END force removal of www IN URL# force www IN URL # 2. start https check RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://example.com/$1 [R,L] # end https check
Comments
Subscribe to comments
You need to login to post a comment.

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]