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

XF 1.1 how to force HTTPS at .htacces xenforo

Discussion in 'XenForo Questions and Support' started by lalalatrululu, Oct 8, 2011.

  1. lalalatrululu

    lalalatrululu Member

    i need to redirect all http pages to https
    how can i do that in xenforo .htaccess file?
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    I don't have a secure cert to really test this, but this should work:

    Redirect 301 / https://www.yoursite.com/
    If this is in a subdirectory then it would be:

    Redirect 301 /subdir https://www.yoursite.com/subdir
  3. rEd86

    rEd86 Active Member

    Fuhrmann likes this.
  4. lalalatrululu

    lalalatrululu Member

  5. rEd86

    rEd86 Active Member

    Some else that's a better with regular expressions can step up and correct me (I just don't do them that often) but I THINK this will work:

    RewriteRule ^(.*/)*$ https://www.yourdomain.com/$1 [R=301,L]

    I also changes the "R" at the end (redirect) to include the code 301, which is a permanent redirect. That way search engines will hit the right place the second time they try and index content.

  6. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    When I searched Google I found lots of people using rewrites for this. I don't like that solution. A redirect seems more appropriate. Though I had trouble finding a way to check the protocol using a redirect, hence the plain redirect in my previous post.
  7. rEd86

    rEd86 Active Member

    Isn't the "R=301" a redirect directive?

  8. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Oh yeah. [​IMG]
  9. Will

    Will Active Member

    If you haven't figured it out, you can also do something like this.

    For example, I use this for my ACP.

    RewriteEngine On
    RewriteCond %{SERVER_PORT} 80
    RewriteCond %{REQUEST_URI} forums/admin.php
    RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [R,L]
    lalalatrululu likes this.

Share This Page