Answer by Milan Krushna for Preserve HTTP/HTTPS protocol in .htaccess redirects
http to https redirection: <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTPS} !on RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L] </IfModule> Non www to www...
View ArticleAnswer by Gerald Schneider for Preserve HTTP/HTTPS protocol in .htaccess...
Starting with Apache 2.4 you can also use the variable %{REQUEST_SCHEME} to preserve the scheme: RewriteRule "^" "%{REQUEST_SCHEME}://sub.domain.com:2368%{REQUEST_URI}" [P,QSA,L] No need to meddle with...
View ArticleAnswer by Magnus Gustavsson for Preserve HTTP/HTTPS protocol in .htaccess...
Or, you might use the solution posted as an answer by Jon Lin and rewrite it to use one RewriteCond and then set a variable as suggested in the answer by TMS. That would look like this: RewriteCond...
View ArticleAnswer by TMS for Preserve HTTP/HTTPS protocol in .htaccess redirects
The trick provided by Jon is a nice hack, but I am afraid it could break if you want to use more [OR] conditions, and if you use more backreferences you have to be careful which number to use (%1 or %2...
View ArticleAnswer by Jon Lin for Preserve HTTP/HTTPS protocol in .htaccess redirects
Try adding a condition like: RewriteCond %{HTTPS} off [OR] RewriteCond %{HTTPS}:s on:(s) Which checks that either HTTPS is off or it's on and you can use a backreference to fetch the "s" character:...
View ArticlePreserve HTTP/HTTPS protocol in .htaccess redirects
I have to redirect port 80 to 2368 in htaccess but I'd like to keep the requested protocol intact so that SSL doesn't break. I currently have this: RewriteCond %{HTTP_HOST} ^sub.domain.com$ [NC]...
View Article