XF 1.4 htaccess non www and SSL?

FredC

Well-known member
How to force both non www and https?

My forum is in a community folder and my htaccess looks like so... (forcing https)
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

    RewriteCond %{SERVER_PORT} 80
    RewriteRule ^(.*)$ https://doberman-chat.com/community/$1 [R,L]

    #    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

    #    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]
</IfModule>

I also have a separate htaccess file in the root directory... (forcing non www)
Code:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]

So the question is how do i get these two rewrites to work together?
------------------------
Edit: I also have a rewrite someplace forcing all traffic from my root domain to the community folder. IE: mysite.com redirects to mysite.com/community

will i ever be able to get all these to play together?
 
Last edited:
@FredC, if you want to start a convo with me, I can take a look at installing it for you. You will have to provide some info (which will be better done via convo or Skype). I'm heading off to a nap shortly and won't be available for at least around 20 hours (nap and then some work I have to do).
 
@FredC, if you want to start a convo with me, I can take a look at installing it for you. You will have to provide some info (which will be better done via convo or Skype). I'm heading off to a nap shortly and won't be available for at least around 20 hours (nap and then some work I have to do).
Thank you for the kind offer @Tracy Perry but I have already been issued a refund for the certificate. I really couldn't imagine what a nightmare it must be to keep everything compatible with SSL I don't think I'm up to the task for such little in return.
 
Thank you for the kind offer @Tracy Perry but I have already been issued a refund for the certificate. I really couldn't imagine what a nightmare it must be to keep everything compatible with SSL I don't think I'm up to the task for such little in return.
If you decide you want to try it later, the offer will still be good.

I just got through battling with CentOS and Postfix on my Linux site (first site I've had fully on CentOS). The bounce mail handling wasn't working with VERP enabled. Amazing what a simple little config line of
Code:
recipient_delimiter = +
will do if it's missing. :confused:
 
Thank you for the kind offer @Tracy Perry but I have already been issued a refund for the certificate. I really couldn't imagine what a nightmare it must be to keep everything compatible with SSL I don't think I'm up to the task for such little in return.
It's really not that hard. It can be done in less than 10 minutes tops from issuing to setup. Setup my static subdomain with a cert earlier today.
 
It's with all servers, not just nginx. The certificate issuer and other validation certs need to be combined with the cert.
I believe (but not sure) that cPanel (which is what he is using) pretty much does that for you - all you have to do is put the info in (or point it at the certs). I don't use cPanel so can't tell you for sure (last time I used it was when I got started on HostGator and that was only for a few months).
 
It's really not that hard. It can be done in less than 10 minutes tops from issuing to setup. Setup my static subdomain with a cert earlier today.
I have no doubts it's simple enough. Just not simple enough for me. It's only but for sheer luck that the server even chugs along with me as it's only manager.
 
I'd take @Tracy Perry up on his offer to help. Keep in mind that this isn't just about Google ranking, they're offering a slight signal advantage because they'd like to incentivize the web to switch to secure as a best practice.

With Https, member logins and conversations are encrypted from PC to server to pc. This is a good thing for forum members even if you aren't handling credit cards
 
I believe (but not sure) that cPanel (which is what he is using) pretty much does that for you - all you have to do is put the info in (or point it at the certs). I don't use cPanel so can't tell you for sure (last time I used it was when I got started on HostGator and that was only for a few months).
Never used cPanel, or any panel for that matter, myself either. I mean, I've used it a few times for clients as I can set it up and secure a server running it correctly, but I don't really use it so I wouldn't know. Generally speaking though, on a normal CLI you'd need to combine the certs.
 
ugh repurchased.. You guys are pretty convincing.. Of course security is important to me as i value my members but i really didnt think it that practical for a site that only uses PP for transactions..
 
Download the Intermediate and Primary Certificate to where you keep your certificates and key files on the server
Lost already?

Click on Setup a SSL certificate to work with your site. If this option is not available, your web host may have disabled it. You will need to contact them about how to install the Intermediate certificate
This is where i think things start going south for me.. This option is not present in Neither WHM or Cpanel.

In the box labeled Ca Bundle paste the contents of the Intermediate certificate Click Install Certificate. Your SSL certificate should now be installed, and the website configured to accept secure connections. You or your web host may need to restart Apache before it will work
This is also messing things up i believe because i have never been provided with a Ca Bundle..
 
This is also messing things up i believe because i have never been provided with a Ca Bundle..
cPanel/CentOS apparently pulls it in automatically (even the cPanel screen shows you may not need to enter it) and apparently concatenates them for you...
But, as it is.. somebodys site is now HTTPS. :D
 
How to force both non www and https?

My forum is in a community folder and my htaccess looks like so... (forcing https)
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

    RewriteCond %{SERVER_PORT} 80
    RewriteRule ^(.*)$ https://doberman-chat.com/community/$1 [R,L]

    #    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

    #    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]
</IfModule>

I also have a separate htaccess file in the root directory... (forcing non www)
Code:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]

So the question is how do i get these two rewrites to work together?
------------------------
Edit: I also have a rewrite someplace forcing all traffic from my root domain to the community folder. IE: mysite.com redirects to mysite.com/community

will i ever be able to get all these to play together?


Hello, what is the solution in the .htaccess?
Thanks and regards.
 
Hello, what is the solution in the .htaccess?
Thanks and regards.


This is all I do:

Code:
#toredirect from http to https

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

#toredirect from www to non www
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*) https://%1/$1 [R=301,L]
 
This is all I do:

Code:
#toredirect from http to https

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

#toredirect from www to non www
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*) https://%1/$1 [R=301,L]
Hi, I'll try thank you very much.
 
This is all I do:

Code:
#toredirect from http to https

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

#toredirect from www to non www
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*) https://%1/$1 [R=301,L]


Hi, I just try and throws me error.
I think I must have something wrong in my httacess.
You can look at my code please if something is wrong and tell me where to put it?
Because I've tried several options and does not work.
Do not load the page fails is all white.
rare errors.
Thank you very much.

# 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

# Z
RewriteCond %{HTTP_HOST} ^www\.([^.]+)\.([^.]+)$
RewriteRule ^(.*)$ http://%1.%2/$1 [R=301,L]
# /Z


# 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

# 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]



Options +FollowSymlinks
#Protect against hotlinking
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www.)?MyWEB.com/ [nc]
RewriteRule .*.(gif|jpg|png|jpeg)$ http://MyWEB.com/imagenes/norobarimagenes.jpg[nc]
</IfModule>

<ifmodule mod_expires.c>
ExpiresActive On
ExpiresDefault A604800
<filesmatch ".(jpg|JPG|gif|GIF|png|css|ico|js)$">
ExpiresDefault "access plus 7 day"
</filesmatch>

<FilesMatch ".(js|css)$">
# 7 days
ExpiresDefault A604800
Header append Cache-Control "public"
</FilesMatch>
</ifmodule>
 
Shorter version without double redirect, but it requires adding precise domain names instead of variables:
Code:
  RewriteEngine On

   RewriteCond %{HTTPS} !=on
   RewriteRule ^(.*)$ https://www.artodia.com/$1 [R=permanent,L]

   RewriteCond %{HTTP_HOST} !^www\.artodia\.com
   RewriteRule ^(.*)$ https://www.artodia.com/$1 [R=permanent,L]
 
Shorter version without double redirect, but it requires adding precise domain names instead of variables:
Code:
  RewriteEngine On

   RewriteCond %{HTTPS} !=on
   RewriteRule ^(.*)$ https://www.artodia.com/$1 [R=permanent,L]

   RewriteCond %{HTTP_HOST} !^www\.artodia\.com
   RewriteRule ^(.*)$ https://www.artodia.com/$1 [R=permanent,L]


Hi, thanks for your response.
But I think my problem is that I put not to display the WWW.
Thank you.
 
Top Bottom