• Welcome to XF2 Addons. All the XF2 addons located in the Resources area are available for download once you upgrade your account to Premium membership. In addition, Premium members will get technical support. Premium membership costs only $35.00 USD a year. Once the year has expired you can continue to use the installed addons on your forum as long as you like.

.htaccess setup


Andy

Administrator
Forum installed in a directory

By default your forum can be accesses with HTTP or HTTPS in the URL.

Code:
https://www.domain.com
http://domain.com
To always force HTTPS you will want add this to your .htaccess file located in the web root:

Code:
RewriteEngine On

RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
 

Andy

Administrator
Forum installed in the web root

By default your forum can be accesses with HTTP or HTTPS in the URL.

Code:
https://www.domain.com
http://domain.com
To always force HTTPS you will want add this to your .htaccess file located in the web root:

pic001.jpg


Code:
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
 

Tourmeister

Well-Known Member
Thanks for the help in getting this squared away on my site!

I thought I would share this so others might use it if they install their forum in a subdirectory like /forums

This is the code in the .htaccess file in my /home/user/public_html
Code:
RewriteEngine On

RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteCond %{HTTP_HOST} ^twtex.com$ [NC]
RewriteRule ^(.*)$ https://www.twtex.com/$1 [R=301,L]
This is the code in the .htacces file in my /home/user/public_html/forums
It is the default XF .htacces file with the two lines from Andy added.

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 405 default
ErrorDocument 406 default
ErrorDocument 500 default
ErrorDocument 501 default
ErrorDocument 503 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 /xenforo

# Force https - provided by Andy
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

    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]
</IfModule>
It works perfect.
 
Top