XF 1.5 htaccess in root not affecting forum in subdirectory

Mr Lucky

Well-known member
I have just switched my forum to SSL.

the forum is in a subdirectroty /forums/ and home page is static html

https://www.logic-users-group.com/forums/

I was under the impression if I put the redirect from http to https in the root .htaccess, then it will also affect the subdirectory but this is not happening.

The forum is only redirecting if it is in the subdirectory htaccess also.

This may not be too much of a problem, but at the saem time I want to strip www, but if this is in the subdriectory as well then the froum redirects back to the root.

I am using this in the root:

Code:
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]



Can anyone help please so I can have redirect in the root that affects subdirectories also? Thanks
 
OK, I have it working but I'm not sure if this is the best way:

In the /forum/ directory:

Code:
DirectoryIndex index.php

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


RewriteCond %{HTTP_HOST} ^www.logic-users-group.com [NC]
RewriteRule (.*) https://logic-users-group.com/forums/$1 [R=301,L]

In the root:

Code:
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]
 
I was under the impression if I put the redirect from http to https in the root .htaccess, then it will also affect the subdirectory but this is not happening.
Not necessarily. In this case, it's because the forum .htaccess has a "catch all" rewrite which is needed for friendly URL support. When this matches, it stops other matches, so it doesn't continue up the directory path.

As such, you need to (roughly) duplicate the rules in the forum directory.
 
Back
Top Bottom