Search code examples
phpurlnetwork-programmingmodxmodx-revolution

ModX non-www resources ->www resources


We just launched a site that had been accessible at a temporary subdomain.company.com. Now that it's available at company.com and www.company.com, we have an internal network issue.

Our network is built on company.com, meaning that internally, company.com resolves to a different IP address than www.company.com will.

So when someone on the network visits www.company.com, resources on our ModX Revolution site that point to a company.com URL do not load. Basically, no images, no CSS, just text appears.

Does anyone know a setting in ModX that can be used to resolve this? Thanks.


Solution

  • If it is acceptable for both company.com and www.company.com to resolve to the same website, you can redirect non-www to www using the following in .htaccess:

    RewriteCond %{HTTP_HOST} .
    RewriteCond %{HTTP_HOST} !^www\.company\.com [NC]
    RewriteRule (.*) http://www.company.com/$1 [R=301,L]