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:
Then remove www. and www\. from all those lines.



Hello, I just testing by removing the WWW as indicas and still gives me a blank page.
You could put if not too much trouble your full .htacess to change mine if something is wrong in mine and try?
Thank you very much.
 
Sure, I'll post it when I get back home.

However that is pretty much full htaccess from my website. The only code its missing are xenforo redirects and few ip bans, but its irrelevant for redirect
 
If you get errors, try replacing
Code:
^(.*)$
with
Code:
^/?(.*)
in both RewriteRule strings

Here is my .htaccess. As I posted above, the rest of file is pretty much irrelevant.

Code:
<IfModule mod_rewrite.c>
   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]
</IfModule>

<IfModule mod_rewrite.c>
   RewriteEngine On
  RewriteCond %{REQUEST_FILENAME} -f [OR]
   RewriteCond %{REQUEST_FILENAME} -l [OR]
   RewriteCond %{REQUEST_FILENAME} -d
   RewriteRule ^.*$ - [NC,L]
   RewriteRule ^(demo/|images/|samples/|layout/|layout2/|downloads/|docs/) - [NC,L]
   RewriteRule ^(data/|js/|styles/|install/|favicon\.ico|crossdomain\.xml|robots\.txt) - [NC,L]
   RewriteRule ^(.*)\.html /html.php [NC,L]
   RewriteRule ^.*$ index.php [NC,L]
</IfModule>

Deny from 94.242.237.
Deny from 188.143.234.27
Deny from 192.184.0.0/22
Deny from 91.79.5.47

# 39.32.0.0 - 39.63.255.255 Pakistan spam
Deny from 39.32.0.0/14
 
Hi guys, thank you very much for your assistance.
But I see that it does not work and do not understand what happens.

@Arty
I've tried changing your domain yours for mine and does not work.
I changed the symbols you told me and does not work, throws 500 error.
And with your parameters same but changing the domain mistake throws me blank page.

@Mr Lucky
For me it does not work, I hope that the problem is not because of cloudflare.
Thank you very much to you both.


And especially to the Lord @Arty, for your time.
Let's see if I can find a solution. I will publish impressions.
 
Top Bottom