jhsachs Posted August 28, 2012 Share Posted August 28, 2012 I'm trying to set up a subdomain for the first time. Something is happening with the URL resolution that I don't understand. The directory structure looks like this: serverRoot home accountRoot subdomainRoot public_html (subdomain document root) include (subdomain's include files) public_html (domain document root) include (domain's include files) When I load subdomain.domain.com, it works. When I load http://subdomain.domain.com, it works. When I load https://subdomain.domain.com, I get an error. By fiddling with the source code, I've determined that the server is actually loading index.php from the root domain instead of the subdomain. The only cause I can think of for this is a rewrite rule, but I think I've eliminated that possibility. There are no rewrite rules that could match https://subdomain.domain.com. Furthermore, the rewrite rules for https and http are exactly equivalent, so any rule that affects one should affect the other. And finally, the effect of a rewrite rule should be visible in the URL shown in the browser's address bar, but it isn't changed. I'm looking for ideas here: what might be wrong? Quote Link to comment https://forums.phpfreaks.com/topic/267700-https-request-loads-script-from-wrong-subdomain/ Share on other sites More sharing options...
Christian F. Posted August 28, 2012 Share Posted August 28, 2012 Please post your configuration and the rewrite rules. People cannot help you without knowing what you've actually tried to do, after all. What you've posted above was what you wanted to accomplish, and what happened, not what you've actually done. Quote Link to comment https://forums.phpfreaks.com/topic/267700-https-request-loads-script-from-wrong-subdomain/#findComment-1373305 Share on other sites More sharing options...
requinix Posted August 28, 2012 Share Posted August 28, 2012 Unless you have SNI enabled in Apache and have a browser modern enough to support it (which I believe almost all of them do by now), there can be only one website served through HTTPS. In your case that would be your "root domain". Best option is to get SNI working, but you need Apache 2.2.12+ and control of the server and/or software. Otherwise you'll have to emulate the subdomain through mod_rewrite. Quote Link to comment https://forums.phpfreaks.com/topic/267700-https-request-loads-script-from-wrong-subdomain/#findComment-1373317 Share on other sites More sharing options...
jhsachs Posted August 28, 2012 Author Share Posted August 28, 2012 If you have reason to believe that the problem is in .htaccess, certainly you need to see it. Here it is; I've done substitutions on the domain names to make them consistent with the OP. Options +FollowSymlinks RewriteEngine on rewritecond %{http_host} ^http://production\.com [nc] rewriterule ^(.*)$ http://www.production\.com/$1 [r=301,nc] rewritecond %{http_host} ^https://production\.com [nc] rewriterule ^(.*)$ https://www.production\.com/$1 [r=301,nc] rewritecond %{http_host} ^http://domain\.com [nc] rewriterule ^(.*)$ http://www.domain\.com/$1 [r=301,nc] rewritecond %{http_host} ^https://domain\.com [nc] rewriterule ^(.*)$ https://www.domain\.com/$1 [r=301,nc] ("domain.com" is the domain on which I'm having this problem, a domain used for QA. "production.com" is the corresponding production domain. The file contains references to both only so that I can use a single version of the .htaccess file in both.) The limitation of one certificate per domain sounds likely to be the problem, though. If so, I can eliminate it by moving the site to another domain name, which probably won't be a big deal. I'll contact the client to ask if I can use one of their parked names. Quote Link to comment https://forums.phpfreaks.com/topic/267700-https-request-loads-script-from-wrong-subdomain/#findComment-1373385 Share on other sites More sharing options...
requinix Posted August 28, 2012 Share Posted August 28, 2012 You can keep the same name - you just need a different installation of Apache. Quote Link to comment https://forums.phpfreaks.com/topic/267700-https-request-loads-script-from-wrong-subdomain/#findComment-1373387 Share on other sites More sharing options...
jhsachs Posted August 28, 2012 Author Share Posted August 28, 2012 I'm not sure which version of Apache is installed; phpinfo doesn't say, and I haven't had time to research it otherwise. If the version of Apache doesn't support SNI, replacing it is not an option. It's on a managed server, and neither my client nor I would be prepared to roll our own. Quote Link to comment https://forums.phpfreaks.com/topic/267700-https-request-loads-script-from-wrong-subdomain/#findComment-1373408 Share on other sites More sharing options...
requinix Posted August 28, 2012 Share Posted August 28, 2012 Right. My point was that you can use that subdomain just fine so long as it resolves to and ends up at a second installation of Apache (of whatever version you want). Don't need to bring in something else. Quote Link to comment https://forums.phpfreaks.com/topic/267700-https-request-loads-script-from-wrong-subdomain/#findComment-1373430 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.