MyBB Community Forums

Full Version: Assistance with .htaccess file
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
probably off topic but I'll try anyway.  
I have a domain "chronicsuicidesupport.com" (hereafter "CSS.com") with an unrelated subdomain "aljones.us" (history / genealogy)

Since my hosting company has been pushing the move to https (ssl cert) I called them and asked for some help since I don't know .htaccess writing.

They modified the existing .htaccess to:
RewriteEngine on
RewriteOptions inherit
# Use PHP5.4 Single php.ini as default
# Changed PHP handler from application/x-httpd-php54s to application/x-httpd-phpbetas on Tue Jan 12 04:05:21 MST 2016.
AddHandler application/x-httpd-phpbetas .php
#RewriteCond %{HTTP_HOST} ^chronicsuicidesupport\.com$ [OR]
#RewriteCond %{HTTP_HOST} ^www\.chronicsuicidesupport\.com$
#RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
#RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
#RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
#RewriteRule ^/?$ "https\:\/\/www\.chronicsuicidesupport\.com\/" [R=301,L]
#RewriteEngine on
#RewriteCond %{HTTP_HOST} ^chronicsuicidesupport.com [NC,OR]
#RewriteCond %{HTTP_HOST} ^www.chronicsuicidesupport.com [NC]
#RewriteRule ^(.*)$ https://www.chronicsuicidesupport.com/$1 [L,R=301,NC]
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://chronicsuicidesupport.com/$1 [R=301,L]

Prior to their "assistance", I could get http://chronicsuicidesupport.com and http://aljones.us without problem.  After their change, any attempt to goto aljones.us dumps my user into CSS.com

If I'm reading this correctly, the RewriteComd take any {HTTP_HOST} (which I presume are aljones.us or CSS.com??) and attempts to dump it into CSS.com.

My question, if you can help, is how do I modify this so that requests for aljones.us goto aljones.us not CSS.com

I realize this is probably off topic for MyBB but I need some help!
The problem is that this rule
RewriteRule ^/?$ "https\:\/\/www\.chronicsuicidesupport\.com\/" [R=301,L]

Catches all requests, regardless of the domain the visitors entered. 

Better use sth like this:
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
I thought I had notifications set but I never saw a notification re your response.

I thought that was the culprit but didn't know what to use to replace it, thank you.

We now look like this:
RewriteEngine on
RewriteOptions inherit
# Use PHP5.4 Single php.ini as default
# Changed PHP handler from application/x-httpd-php54s to application/x-httpd-phpbetas on Tue Jan 12 04:05:21 MST 2016.
AddHandler application/x-httpd-phpbetas .php
#RewriteCond %{HTTP_HOST} ^chronicsuicidesupport\.com$ [OR]
#RewriteCond %{HTTP_HOST} ^www\.chronicsuicidesupport\.com$
#RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
#RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
#RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
#RewriteCond %{HTTPS} !=on
#RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
#RewriteEngine on
#RewriteCond %{HTTP_HOST} ^chronicsuicidesupport.com [NC,OR]
#RewriteCond %{HTTP_HOST} ^www.chronicsuicidesupport.com [NC]
#RewriteCond %{HTTPS} !=on
#RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
#RewriteCond %{SERVER_PORT} 80 
#RewriteRule ^(.*)$ https://chronicsuicidesupport.com/$1 [R=301,L]

If you don't mind a couple of dumb questions,
1) I assumed that all  lines beginning with a hash mark would be comments until I looked at the .htaccess file where almost all my lines begin with a "#", why does this work at all??
2) if I try to access "http://css.com" my browser says that it's non-secure
if I access "https://ccs.com" it's the secure version ...
which is really okay since most of my users user "https://" but it just struck me as odd.

CCS is a somewhat active working forum, I really don't want to spend a lot of time "trying this or that" since I don't want to aggravate my users, so I do appreciate your help.
//al
I don't think your rules are working i.o.w the #'s are working to comment out rules, since you say that http does not redirect to https, but you have the rule there:

#RewriteCond %{HTTPS} !=on
#RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]