Craft Pro 2.4.2702
Experiencing an intermittent issue with a Craft site that randomly crops up. It always seems to occur randomly with the caching and the "www" prefix and URLs being cached.
In a Redactor WYSIWYG field, this is the markup.
<a href="https://www.mysite.org/privacy-policy#entry:585:url">Privacy Policy</a>
Randomly at times the page, the page URL links will be cached like so. Notice the eww.mysite.org. I've seen other instances where it's been ww.mysite.org/page-url, eee.mysite.org/page-url, htp.mysite.org, wee.mysite.org for all URLs that are being cached in the craft_templatecaches table. The urls are generated by entry.getUrl()
, but also are manually typed in using a WYSIWYG field.
With my previous example, this is how it's being cached in the database
<a href="https://eww.mysite.org/privacy-policy">Privacy Policy</a>
Majority of the caching on the site is done like so.
{%- cache globally unless craft.config.devMode -%}
...
{%- endcache -%}
At first I thought this might have been the wildcard in the DNS (*.mysite.org) and the page was still resolving with any prefix value and the URLs were being cached like so. I since then have removed the wildcard from the DNS, the page no longer resolves with an incorrect prefix, and this issue seems to pop up randomly.
In my general.php config.
define('URI_SCHEME', ( isset($_SERVER['HTTPS'] ) ) ? "https://" : "http://" ); define('SITE_URL', URI_SCHEME . 'www.' . $_SERVER['SERVER_NAME'] . '/');
Htaccess file.
# ---------------------------------------------------------------------- # Rewrite Craft URLs to remove index.php # ---------------------------------------------------------------------- RewriteEngine On # ---------------------------------------------------------------------- # Force "www." to beginning of URLs # http://stackoverflow.com/questions/4916222/htaccess-how-to-force-www-in-a-generic-way # ---------------------------------------------------------------------- RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteCond %{HTTP_HOST} ^mysite.org [NC] RewriteCond %{HTTPS}s ^on(s)| RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L] # Send would-be 404 requests to Craft RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !^/(favicon\.ico|apple-touch-icon.*\.png)$ [NC] RewriteRule (.+) index.php?p=$1 [QSA,L]