Redirect to a HTTPS version using .htaccess -


i need modify .htaccess file redirect urls https version without "www".

http://example.com --> https://example.com http://www.example.com --> https://example.com https://www.example.com --> https://example.com 

this how .htaccess file looks like:

rewriteengine on rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewriterule ^(.*)$ redirect.php?id=$1&page=$2 [qsa,l] 

what modifications need make .htaccess in order forward https without "www"?

it depends on doing current code. looks file called redirect trying display php page seo friendly url. think might confusing people.

anyway, need , force https without www, need 1 more rule above.

also second rule needs two capture groups in rewriterule test string because wanting 2 different values using $1 , $2 references.

rewriteengine on  #rediect www non www and/or http https --- combinations. rewritecond %{http_host} !^example\.com [nc,or] rewritecond %{https} !^on rewriterule ^ https://example.com%{request_uri} [r=301,l]  rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewriterule ^(.+)/(.+)/?$ redirect.php?id=$1&page=$2 [qsa,l] 

so second rule work url formed this.

https://example.com/123/pagename 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -