bestrong Posted February 8, 2010 Share Posted February 8, 2010 Hello, I have a website where I need to: redirect all http requests to https and remove the www from all requests. For example http://mysite.com -> https://mysite.com http://www.mysite.com -> https://mysite.com http://www.mysite.com/accounts -> https://mysite.com/accounts www.mysite.com -> https://mysite.com https://www.mysite.com -> https://mysite.com is there any way of doing this? I tried and tried in .htaccess with url rewriting ... but I got all sorts of unexpected results. please help thanks Link to comment https://forums.phpfreaks.com/topic/191402-htaccess-redirect-help/ Share on other sites More sharing options...
teamatomic Posted February 8, 2010 Share Posted February 8, 2010 First we do the www url, NC = case insenitive OR = or So we are first removing a www and if it is true we drop to the rewrite rule, if false the next condition. The second rewrite rule does the domain sans www and drops to the rewrite rule. RewriteEngine On RewriteCond %{HTTP_HOST} ^www.domain.com$ [NC,OR] RewriteCond %{HTTP_HOST} domain.com$ [NC] RewriteRule ^(.*)$ https://domain.com/$1 [R=301,L] HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/191402-htaccess-redirect-help/#findComment-1009151 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.