Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
jgulledge19 opened this issue Jun 26, 2012 · 4 comments
Closed

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

jgulledge19 opened this issue Jun 26, 2012 · 4 comments

Comments

@jgulledge19
Copy link

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
Copy link
Owner

Mark-H commented Jun 26, 2012

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
Copy link
Author

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 added a commit that referenced this issue Jul 18, 2012
New functions according to issues #2 (www + no-www support) and #3 (http_host_aliases).
@Mark-H
Copy link
Owner

Mark-H commented Jul 18, 2012

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

@Mark-H Mark-H closed this as completed Jul 18, 2012
@jgulledge19
Copy link
Author

Awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants