Wednesday, 15 May 2013

linux - With htaccess .. all url must be redirect to https with www -



linux - With htaccess .. all url must be redirect to https with www -

domain.com www.domain.com/xyz http://domain.com/xyz http://www.domain.com/xyz https://domain.com/xyz

must redirect below .htaccess (apache 2.4)

https://www.domain.com/xyz

place rule in document_root/.htaccess file:

rewriteengine on rewritecond %{https} off [or] rewritecond %{http_host} !^www\. [nc] rewriterule ^ https://www.domain.com%{request_uri} [r=302,l,ne]

edit: testing using curl command line:

$> curl -i -k -a "chrome" -l 'https://domain.com/' http/1.1 302 found date: wed, 25 jun 2014 06:50:57 gmt server: apache/2.4.7 (ubuntu) location: https://www.domain.com/ content-type: text/html; charset=iso-8859-1 http/1.1 200 ok date: wed, 25 jun 2014 06:51:00 gmt server: apache/2.4.7 (ubuntu) last-modified: thu, 19 jun 2014 13:16:20 gmt etag: "7ac-4fc302ecafc5e" accept-ranges: bytes content-length: 1964 vary: accept-encoding content-type: text/html

linux apache .htaccess mod-rewrite ubuntu

No comments:

Post a Comment