News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

What is the htaccess for smf to redirect all pages to https as default url?

Started by humbleworld, January 28, 2017, 03:32:47 AM

Previous topic - Next topic

humbleworld

What is the htaccess for smf to redirect all pages to https as default url?
By the way, I am also using pretty urls. I am getting errors after I redirect all pages to https. I have ssl certificates installed.

Shambles

I use the following:


RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.mysite.com/$1 [R,L]


I don't use those pretty things.


Steve

DO NOT pm me for support!

humbleworld

Steve, I got a problem. I noticed that after implementing the .htaccess code, I could no longer make a post on my forum site.

Kindred

did you correctly reconfigure your entire site for https, including pretty urls?

because I use the htaccess (forced redirect) for https and can post just fine on 5 different sites.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Illori


humbleworld

Hi Illori,

# PRETTYURLS MOD BEGINS
# Pretty URLs mod
# http://code.google.com/p/prettyurls/
# .htaccess file generated automatically on: January 18, 2017, 22:09

RewriteEngine on
RewriteBase /

# Rules for: actions
RewriteRule ^(activate|admin|ads|announce|attachapprove|bookmarks|buddy|calendar)/?$ ./index.php?pretty;action=$1 [L,QSA]
RewriteRule ^(clock|collapse|coppa|credits|deletemsg|display|dlattach|editpoll)/?$ ./index.php?pretty;action=$1 [L,QSA]
RewriteRule ^(editpoll2|mediapro|emailuser|findmember|forum|portal|groups|help)/?$ ./index.php?pretty;action=$1 [L,QSA]
RewriteRule ^(gallery|helpadmin|im|jseditor|jsmodify|links|jsoption|lock)/?$ ./index.php?pretty;action=$1 [L,QSA]
RewriteRule ^(lockvoting|login|login2|logout|markasread|mergetopics|mlist|moderate)/?$ ./index.php?pretty;action=$1 [L,QSA]
RewriteRule ^(modifycat|modifykarma|movetopic|movetopic2|notify|notifyboard|openidreturn|pm)/?$ ./index.php?pretty;action=$1 [L,QSA]
RewriteRule ^(post|post2|printpage|profile|quotefast|quickmod|quickmod2|recent)/?$ ./index.php?pretty;action=$1 [L,QSA]
RewriteRule ^(register|register2|reminder|removepoll|removetopic2|reporttm|requestmembers|restoretopic)/?$ ./index.php?pretty;action=$1 [L,QSA]
RewriteRule ^(search|search2|sendtopic|smstats|suggest|spellcheck|splittopics|stats)/?$ ./index.php?pretty;action=$1 [L,QSA]
RewriteRule ^(sticky|feedsadmin|theme|trackip|about:mozilla|about:unknown|unread|unreadreplies)/?$ ./index.php?pretty;action=$1 [L,QSA]
RewriteRule ^(verificationcode|viewprofile|vote|viewquery|viewsmfile|who|\.xml|xmlhttp)/?$ ./index.php?pretty;action=$1 [L,QSA]

# Rules for: boards
RewriteRule ^([-_!~*'()$a-zA-Z0-9]+)/?$ ./index.php?pretty;board=$1.0 [L,QSA]
RewriteRule ^([-_!~*'()$a-zA-Z0-9]+)/([0-9]*)/?$ ./index.php?pretty;board=$1.$2 [L,QSA]

# Rules for: topics
RewriteRule ^([-_!~*'()$a-zA-Z0-9]+)/([-_!~*'()$a-zA-Z0-9]+)/?$ ./index.php?pretty;board=$1;topic=$2.0 [L,QSA]
RewriteRule ^([-_!~*'()$a-zA-Z0-9]+)/([-_!~*'()$a-zA-Z0-9]+)/([0-9]*|msg[0-9]*|new)/?$ ./index.php?pretty;board=$1;topic=$2.$3 [L,QSA]

# PRETTYURLS MOD ENDS

Linkjay

Hey Humble,

If your host allows having custom SSL certificates on your server, then you should look into CloudFlare. They offer free SSL, DDoS protection, site antalytics, etc.  Their free plan gives you just about all you need and is free forever unless you upgrade. CloudFlare has features that can give https (SSL) for your forums and allows content to always be served over https so this would solve your issue here on this topic.
I play games in my free time and volunteer my knowledge and support to the gaming communities of the internet.

You can contact me by these methods:
Use my Contact Script • PM me here • Add me on Steam

Black Tiger

You can also better use a 301 redirect for Google in that case. I only have a short .htaccess which is working fine.
This one also redirects your domain without www to your domain with www and it works with the domains people use in their browser so it also works for your domain pointers:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]


Ofcourse you have to change your paths in SMF from http to https too.
I don't use pretty urls though, but I use the free Letsencrypt SSL certificate.
Greetings, Black Tiger

humbleworld

hi Black Tiger,

Thank you. How can I modify your https redirect?
My forum does not use www and it is sitting on a sub-domain.

Kindred

Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

humbleworld

After using the new .htaccess, the forum could no longer post. If I post a new topic, I would land on blank new topic page. How to fix this?

Kindred

I suspect prettyurls sinc3 I have 4 sites running https with no issues
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Arantor

That and the forum probably doesn't have https set up properly, so that the post is sent to a http:// URL, redirects, drops everything as part of the redirect, and leaves you on a blank new topic page.

Advertisement: