Author Topic: htaccess problem  (Read 5451 times)

ober

  • Ashton Shagger
  • Ass Wipe
  • Posts: 14305
  • Karma: +73/-790
  • mini-ober is taking over
    • Windy Hill Web Solutions
htaccess problem
« on: January 15, 2015, 11:25:58 PM »
So I have a site: https://www.americanbeautytools.com

I just finished the mobile version which is in public_html/mobile and I created a subdomain: m.americanbeautytools.com

When I go to m.americanbeautytools.com it seems to work... firefox is being a bitch at the moment but Chrome works.  But when I go to https://m.americanbeautytools.com it redirects to the full (www) version! 

I just upgraded the SSL certificate to a wildcard certificate so the https should work for both but it seems like the root htaccess is overriding the subdomain and the htaccess in that folder. 

Relevant root htaccess part:
Code: [Select]
RewriteCond %{HTTP_HOST} ^resistancesoldering.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.resistancesoldering.com$
RewriteRule ^(.*)$ "http\:\/\/www\.resistancesoldering\.com/site" [R=301]
RewriteCond %{HTTP_HOST} ^solderingsolutions.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.solderingsolutions.com$
RewriteRule ^(.*)$ "https\:\/\/www\.americanbeautytools\.com" [R=301]
>>>>RewriteCond %{HTTP_HOST} ^americanbeautytools.com$ [NC]
>>>>RewriteRule ^(.*)$ https://www.americanbeautytools.com/$1 [R=301,L]
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [NC,L]

The htaccess in the mobile folder doesn't do any redirects and there are no redirects in cpanel for the main domain or the subdomain.

Help?  I thought it was the lines with '>>>>' but even when I comment that out it does the same thing.

Mike

  • Jackass In Charge
  • Posts: 11248
  • Karma: +168/-32
  • Ex Asshole - a better and more caring person.
Re: htaccess problem
« Reply #1 on: January 16, 2015, 12:03:52 AM »
Quote
just finished the mobile version which is in public_html/mobile and I created a subdomain: m.americanbeautytools.com
:cry:


My first thought is why are you even using rewrite rules for that?  Just use a vhost for m.domain.com with a document root at public_html/mobile


The easiest way to debug this is to enable the rewriteLog and see what it is doing.

ober

  • Ashton Shagger
  • Ass Wipe
  • Posts: 14305
  • Karma: +73/-790
  • mini-ober is taking over
    • Windy Hill Web Solutions
Re: htaccess problem
« Reply #2 on: January 16, 2015, 09:00:32 AM »
What is your issue with the mobile site?  Is it because I didn't make the entire site responsive?  Because there are a ton of reasons for that.

I didn't intend to use rewrite rules for the mobile site at all.  I was planning to use a javascript redirect based on screen size.   Maybe you can explain the vhost comment?  I'm not sure what you mean by that.  The subdomain (m.americanbeautytools.com) is setup as a subdomain through cPanel and the document root for it is public_html/mobile and there is a separate htaccess under that directory to manage the subdomain needs.

I will turn on rewriteLog as you suggest and see what that tells me.  But maybe to clarify the situation, here is the contents of the ticket I submitted this morning:

Quote
My client (americanbeautytools.com) had a wildcard SSL installed on Tuesday of this week. The main site works as expected but the subdomain does not. Going to the subdomain over http works fine and displays the mobile site. Going to the subdomain over https displays the full site.

Full site: https://www.americanbeautytools.com
Mobile site: http://m.americanbeautytools.com

If I go to https://m.americanbeautytools.com it shows https://www.americanbeautytools.com. I can further test this by trying to access a file in the subdomain directly:

http://m.americanbeautytools.com/libs/foundation/css/foundation.min.css pulls up the css file correctly.
https://m.americanbeautytools.com/libs/foundation/css/foundation.min.css redirects to the full website.

There is an htaccess file at the root of the public_html and a second one at the subdomain which has a root of public_html/mobile. I have some redirection in the root htaccess but even when I comment out those rules it continues to ignore the subdomain ONLY when I'm accessing via https.

I'm not sure what else to do at this point. I don't know why simply changing the protocol would force it to behave differently. This is why I'm asking if it is related to the SSL certificate in some way. The ticket I submitted yesterday under Eric's account was responded with issues maybe related to dns/cache, but I'm on a different computer with both of those things flushed this morning and I still get the same result.


Mike

  • Jackass In Charge
  • Posts: 11248
  • Karma: +168/-32
  • Ex Asshole - a better and more caring person.
Re: htaccess problem
« Reply #3 on: January 16, 2015, 09:39:50 AM »
I don't like mobile subdomains and do prefer responsive designs.  One of the issues is linking.  I can't tell you how many times someone will link to a mobile version of something and it looks terrible on the desktop.

vhosts (virtual host) lets you define different hosts based on domain name.  So:
Code: [Select]
<VirtualHost *:80>
  ServerName americanbeautytools.com
  ServerAlias *.americanbeautytools.com resistancesoldering.com *.resistancesoldering.com solderingsolutions.com *.solderingsolutions.com
  Redirect 301 / https://www.americanbeautytools.com/
</VirtualHost>

<VirtualHost *:443>
  ServerName www.americanbeautytools.com
  ServerAlias resistancesoldering.com *.resistancesoldering.com solderingsolutions.com *.solderingsolutions.com
  DocumentRoot /some/path/public_html
  SSLEngine on
  # Other directives as desired
</VirtualHost>

<VirtualHost *:443>
  ServerName m.americanbeautytools.com
  DocumentRoot /some/path/public_html/mobile
  SSLEngine on
  # Other directives as desired
</VirtualHost>

The really nice part is that you can eliminate the need for .htaccess by moving the configs into your apache config which is going to be faster.

Betazep

  • Sunk
  • Founders
  • Posts: 1685
  • Karma: +14/-5
Re: htaccess problem
« Reply #4 on: January 16, 2015, 09:49:58 AM »
Hurry up. I want to buy a solder station for my workbench. Heheh.
"The most likely way for the world to be destroyed, most experts agree, is by accident. That's where we come in; we're computer professionals. We cause accidents." -Nathaniel Borenstein

KnuckleBuckett

  • Jackass In Charge
  • Posts: 8674
  • Karma: +26/-259
  • [url=http://google.com]I search a lot[/url]
Re: htaccess problem
« Reply #5 on: January 16, 2015, 12:20:21 PM »
Shouldn't the Sink get special discounts?

ober

  • Ashton Shagger
  • Ass Wipe
  • Posts: 14305
  • Karma: +73/-790
  • mini-ober is taking over
    • Windy Hill Web Solutions
Re: htaccess problem
« Reply #6 on: January 16, 2015, 02:49:52 PM »
@Mike: I don't have access to the apache config.  This isn't a dedicated server (like one step above shared pretty much).  So I don't think that is a possibility.

On the desire to have 1 responsive site for all, I think we'll have to agree to disagree.  I think they serve different purposes.  Also, when you try to build it all in one you end up supporting a lot of code to single out the different screens and even when you use something like Foundation (which I used for this), you end up with a bunch of HTML in the page that the mobile browser has to load unnecessarily if you're really changing the content drastically for different screens.

It was much easier to code specifically for mobile without worrying about the desktop view.  If I had to consider both it would have taken me twice the amount of time.

Anyways... back to my original issue... the host says it is outside of their support scope so now I have to figure out what is going on.  I need to turn on the logging and see what I get out of that.

ober

  • Ashton Shagger
  • Ass Wipe
  • Posts: 14305
  • Karma: +73/-790
  • mini-ober is taking over
    • Windy Hill Web Solutions
Re: htaccess problem
« Reply #7 on: January 16, 2015, 03:19:47 PM »
Oddly enough, I can't enable the logging directive.  I get a 500 error anytime I try to add it no matter what path I specify.  Now I'm really not sure what to do.

Betazep

  • Sunk
  • Founders
  • Posts: 1685
  • Karma: +14/-5
Re: htaccess problem
« Reply #8 on: January 16, 2015, 05:38:12 PM »
So...

I am not super good at this stuff, but a couple of things I notice.

There is no 302 when you go to https://m.amercianbeautytools.com.  It is also not doing a URL rewrite.  It is just presenting the wrong content.
"The most likely way for the world to be destroyed, most experts agree, is by accident. That's where we come in; we're computer professionals. We cause accidents." -Nathaniel Borenstein

ober

  • Ashton Shagger
  • Ass Wipe
  • Posts: 14305
  • Karma: +73/-790
  • mini-ober is taking over
    • Windy Hill Web Solutions
Re: htaccess problem
« Reply #9 on: January 18, 2015, 11:49:08 AM »
There wouldn't be a 302 if you went straight to the subdomain with https specified.  That is a valid URL and that also wouldn't require a rewrite. I'm going to try just removing the htaccess files completely later and see what happens. If it is still happening then I blame the certificate.

ober

  • Ashton Shagger
  • Ass Wipe
  • Posts: 14305
  • Karma: +73/-790
  • mini-ober is taking over
    • Windy Hill Web Solutions
Re: htaccess problem
« Reply #10 on: January 18, 2015, 11:51:52 PM »
I kept at it with the host support and they eventually fixed it.  It was some kind of issue with the certificate but the guy that fixed it went off shift so he'll hopefully tell me what he changed tomorrow.  Once he did whatever he did it started working like it was supposed to.

ober

  • Ashton Shagger
  • Ass Wipe
  • Posts: 14305
  • Karma: +73/-790
  • mini-ober is taking over
    • Windy Hill Web Solutions
Re: htaccess problem
« Reply #11 on: January 19, 2015, 09:58:36 AM »
Interestingly enough, the host created a vhost configuration to solve it.  Again, I didn't have access to do that or I would have tried it myself.

Betazep

  • Sunk
  • Founders
  • Posts: 1685
  • Karma: +14/-5
Re: htaccess problem
« Reply #12 on: January 19, 2015, 02:32:33 PM »
That is a valid URL and that also wouldn't require a rewrite.

That is sort of what my point was...

You said htaccess wasn't configured.  It isn't doing a redirect.  Therefore not an htaccess problem.

Would be interested in what the whole root cause is.... for my own educational purposes.  (as I had no idea what it was... just trying to follow along with the logic)  I would find it odd that a certificate would do it specifically and would be very interested in how that is possible.  I could see a config issue based on a file not being represented by the cert... but not the cert itself causing a redirect or invalid content.  I don't understand how that could be.
"The most likely way for the world to be destroyed, most experts agree, is by accident. That's where we come in; we're computer professionals. We cause accidents." -Nathaniel Borenstein

ober

  • Ashton Shagger
  • Ass Wipe
  • Posts: 14305
  • Karma: +73/-790
  • mini-ober is taking over
    • Windy Hill Web Solutions
Re: htaccess problem
« Reply #13 on: January 19, 2015, 03:32:30 PM »
I'm not sure.  I don't know if Mike can explain it better or not.  All I know I have been working all along while building the site without https.  When I tried to go through https on the subdomain with a normal certificate it said the certificate wasn't valid, which is technically true.  So we upgraded to a wildcard SSL cert.  Then for whatever reason, accessing the domain through the https caused it to display the main site.  This was the case even when the htaccess files were completely removed from the root and subdomain.  So it was purely related to the SSL cert.  I don't know the reason that would happen either.