Skip to content

Enable HSTS and make sure everything is HTTPS

Solved Configure
25 2 4.6k
  • @phenomlab all WordPress installations for domain or subdirectory is properly getting redirected to www. so i don’t want to add any rules in main ht access

    i want all requests to “ask” folder to be converted to www. https://www.domain.com/ask

    only flarum is not doing www. redirection

    if writing a global rule is the right approach i will try that

    @hari You should leverage the .htaccess inside the Flarum root directory and not touch anything else. If you set the forward here, it should work as planned.

    Let me know if you need any help.

  • @hari You should leverage the .htaccess inside the Flarum root directory and not touch anything else. If you set the forward here, it should work as planned.

    Let me know if you need any help.

    @phenomlab yes i want you to suggest/modify this for me

    RewriteCond %{HTTP_HOST} ^yourdomain.com/ask [NC]
    RewriteRule ^(.*)$ http://www.yourdomain.com/ask/$1 [L,R=301]
    

    if i use this line in the subdirectory (flarum) it will redirect to to http?

    could you suggest me a line which only modify non www to www and doent touch the https or http thing since DNS is taking care of it.

  • @phenomlab yes i want you to suggest/modify this for me

    RewriteCond %{HTTP_HOST} ^yourdomain.com/ask [NC]
    RewriteRule ^(.*)$ http://www.yourdomain.com/ask/$1 [L,R=301]
    

    if i use this line in the subdirectory (flarum) it will redirect to to http?

    could you suggest me a line which only modify non www to www and doent touch the https or http thing since DNS is taking care of it.

    @hari said in Enable HSTS and make sure everything is HTTPS:

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

    Before we do that, shouldn’t

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

    Actually be

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

    ?

  • @hari said in Enable HSTS and make sure everything is HTTPS:

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

    Before we do that, shouldn’t

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

    Actually be

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

    ?

    @phenomlab nope it’s not working - added these lines in ask direcotry htacess

      RewriteEngine on
       RewriteCond %{HTTP_HOST} ^domain.com/ask [NC]
       RewriteRule ^(.*)$ https://www.domain.com/ask/$1 [L,R=301]
    

    tried to redirect at main folder too but its not redirecting to www for ask

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

    let me try CF page rule

  • @phenomlab nope it’s not working - added these lines in ask direcotry htacess

      RewriteEngine on
       RewriteCond %{HTTP_HOST} ^domain.com/ask [NC]
       RewriteRule ^(.*)$ https://www.domain.com/ask/$1 [L,R=301]
    

    tried to redirect at main folder too but its not redirecting to www for ask

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

    let me try CF page rule

    @hari CF page rule is working, i think my .htacces don’t work 😄

    496e91f4-2bb4-47a0-a946-ad9fe8dd36e8-image.png

    • Solved
  • Hariundefined Hari has marked this topic as solved on
  • phenomlabundefined phenomlab unlocked this topic on

Did this solution help you?
Did you find the suggested solution useful? Support 💗 Sudonix with a coffee
If your organisation needs deeper expertise around infrastructure, security, or technology leadership, learn more about Phenomlab Ltd. Many of the deeper technical guides behind Sudonix are published there.

Related Topics