• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 1.4 [RESOLVED] .htaccess forcing rewrites for https?

#1
Anyone good with .htaccess? Looking to force it so that when people type http:// or www.sitename.com they are redirected to https://www.sitename.com

Code:
#   Mod_security can interfere with uploading of content such as attachments. If you
#   cannot attach files, remove the "#" from the lines below.
#<IfModule mod_security.c>
#   SecFilterEngine Off
#   SecFilterScanPOST Off
#</IfModule>

ErrorDocument 401 default
ErrorDocument 403 default
ErrorDocument 404 default
ErrorDocument 500 default
<IfModule mod_rewrite.c>
  RewriteEngine On
  #  If you are having problems with the rewrite rules, remove the "#" from the
  #  line that begins "RewriteBase" below. You will also have to change the path
  #  of the rewrite to reflect the path to your XenForo installation.
  # RewriteBase /home/sitename/public_html
  #  This line may be needed to enable WebDAV editing with PHP as a CGI.
  #RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
  RewriteCond %{REQUEST_FILENAME} -f [OR]
  RewriteCond %{REQUEST_FILENAME} -l [OR]
  RewriteCond %{REQUEST_FILENAME} -d
  RewriteRule ^.*$ - [NC,L]
  RewriteRule ^(data/|js/|styles/|install/|favicon\.ico|crossdomain\.xml|robots\.txt) - [NC,L]
  RewriteRule ^.*$ index.php [NC,L]
  RewriteCond %{HTTPS} !=on
  RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>
There is my current code but it doesn't seem to be workin; at least with my Chrome.
 

Tracy Perry

Well-known member
#2
@MichaelCS, you should update to let folks know (so that they don't spend time figuring it out) that you resolved this by moving the
Code:
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
to the top of the .htaccess so it was the first thing processed. ;)
 
#3
I would have updated mate but we had a structure fire call come in and I had to leave my laptop running while I took the lads and responded to the call.

I'll update it now ;)
 

Tracy Perry

Well-known member
#4
I would have updated mate but we had a structure fire call come in and I had to leave my laptop running while I took the lads and responded to the call.

I'll update it now ;)
Sorry... structure fires are no excuse... we all know you guys have to run by the local store to grab the marshmellows, graham crackers and chocolate for use.

Just kidding... was a cop myself and ran on several structure fires with the guys... not to mention a time or two having to swing by the station to turn off their stove/oven because one of them had forgotten as they rolled out. :whistle:
Needless to say, the one that forgot usually didn't again.. KP duty was not fun for them.
 
#5
Sorry... structure fires are no excuse... we all know you guys have to run by the local store to grab the marshmellows, graham crackers and chocolate for use.

Just kidding... was a cop myself and ran on several structure fires with the guys... not to mention a time or two having to swing by the station to turn off their stove/oven because one of them had forgotten as they rolled out. :whistle:
Needless to say, the one that forgot usually didn't again.. KP duty was not fun for them.
Hahahahaha, that is what Probies are for!!!

I should have known you were a Blue Canary ;) You know why Firemen have wrinkles? Pillows.

You know why God invented Firefighters? Cops need heroes too!