Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Allow www.domain.com and domain.com #2

Closed
jgulledge19 opened this Issue · 4 comments

2 participants

@jgulledge19

I have several domains on single MODX Revolution install. And someone noticed last week that the "www" was not working. I set the http_host of the context to domain.com. Unless I missed something, with the way the plugin works I need to create another context to have the www.

Here is a simple work around I did to get this to work, it would go around line 35:

$whost = substr($host,4); // ADDED
if (array_key_exists($host, $contexts)) {
$modx->switchContext($contexts[$host]);
} else if (array_key_exists($whost, $contexts)) { // ADDED the else if
$modx->switchContext($contexts[$whost]);
}

Forgive me for being lazy and not doing a pull request.

Thanks!

@Mark-H
Owner

Thanks for the report, Josh.

It's actually known problem and one I'm not sure of what to do with.

I am using a patched plugin for this problem on one site, but in general I would consider it the devs' job to properly force www or no-www through htaccess or similar. My patch actually writes the www. version to the context cache file as well (essentially creates two items per context).

So the question is... do we want to force both to work, or tell the dev to make sure to pick whatever works best.

@jgulledge19

I guess I would recommend looking at this as 2 separate issues.

  1. www.domain.com and domain.com point to the same site so they both work
  2. there is a forced redirect from www.domain.com to domain.com or vice verse.

I would think most people would want #1 to always work and then there are some that want #2. To make things easier, if MODX could do both 1 & 2. We are on IIS and htaccess does not work and I not sure how to make many domains go to www or no www that points to the same files.

@Mark-H Mark-H referenced this issue from a commit
@Mark-H Major refactor and release 1.1.0-pl.
New functions according to issues #2 (www + no-www support) and #3 (http_host_aliases).
ec50a57
@Mark-H
Owner

There's now a system setting includeWww to toggle this behavior. It defaults to on.

@Mark-H Mark-H closed this
@jgulledge19

Awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.