WordPress.org

Support

Support » Plugins and Hacks » After W3 Total Cache redirect domain.de to www.domain.de does not work!

After W3 Total Cache redirect domain.de to www.domain.de does not work!

  • Hello.

    I am using W3 Total Cache since two days. There was a redirect from http://domain.de to http://www.domain.de which does not work anymore. I asume that it is caused by the new htaccess file.

    # BEGIN W3 Total Cache
    <IfModule mod_setenvif.c>
    SetEnvIfNoCase Accept-Encoding (gzip) APPEND_EXT=.$1
    </IfModule>
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_URI} \/$
    RewriteCond %{REQUEST_URI} !(\/wp-admin\/|\/xmlrpc.php|\/wp-(app|cron|login|register).php|wp-.*\.php|index\.php) [OR]
    RewriteCond %{REQUEST_URI} (wp-comments-popup\.php|wp-links-opml\.php|wp-locations\.php) [NC]
    RewriteCond %{REQUEST_METHOD} !=POST
    RewriteCond %{QUERY_STRING} =””
    RewriteCond %{HTTP_COOKIE} !(comment_author|wp-postpass|wordpress_\[a-f0-9\]\+|wordpress_logged_in) [NC]
    RewriteCond %{HTTP_USER_AGENT} !(bot|ia_archive|slurp|crawl|spider) [NC]
    RewriteCond /is/htdocs/wp1150069_94fgh4555K/www/mod/wp-content/w3tc/pgcache/$1/_default_.html%{ENV:APPEND_EXT} -f
    RewriteRule (.*) wp-content/w3tc/pgcache/$1/_default_.html%{ENV:APPEND_EXT} [L]
    </IfModule>
    # END W3 Total Cache

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule .* index.php [L]
    </IfModule>
    # END WordPress

    What exactly do I have to change to make the redirect work again?

    Thank you!

    http://wordpress.org/extend/plugins/w3-total-cache/

Viewing 15 replies - 1 through 15 (of 30 total)
  • I don’t see any directives for the redirect. If they were lost you need to restore them at the top of the file.

    Actually there has not been any directives before. As far as I know WordPress redirects automatically. Unfortunately this redirect does not work anymore since there are the new lines of code from W3 Total Cache in the htaccess file.

    So I guess that the code from W3 Total Cache has to be modified to make the redirect work again.

    Any ideas?

    So I guess that the code from W3 Total Cache has to be modified to make the redirect work again.

    W3TC does not change how WP handles URLs. Disable the plugin and see if the issue is resolved to confirm that the issue is W3TC.

    Hi,

    When i put this code on the top of my htaccess everything ok

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^domain.com$
    RewriteRule ^(.*) http://www.domain.com/$1 [QSA,L,R=301]

    but when W3TC update cache this code move down and problem come back :

    http://www.domain.com/wp-content/w3tc/pgcache/_default_.html.gzip when try http://domain.com

    :'(

    This issue is fixed in the next release. Simply make your changes after enabling disk enhanced page cache and all will be fine for now.

    W3TC does not change how WP handles URLs. Disable the plugin and see if the issue is resolved to confirm that the issue is W3TC.

    I did what you asked me to do. I deactivated the plugin and right after doing this the redirect does work again! So it seems that W3TC does change how WP handles URLS…

    Unfortunately I tried the code posted above from “kento” and this does work for me!! Thanks!

    Just wanted to tell you, that W3TC does something with the URL handling…

    It doesn’t change how WP works, but it does affect other rules you may have, being that they are an unknown quantity. Yours is actually not a common issue.

    I have the same exact problem. so its common problem using 2.9.2. When i deactivate w3 all fine and non www go to www but when activating w3 total cache its stop pointing to http://www.. w3 total catch doing something with url.. anyone know any fix to this ?

    got my site fixed

    here is how for anyone who need it..
    use this code in your htaccess (make sure its on top before anything els)

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

    this simply change all non www links to www good for SEO and search engines

    FYI: Search engines don’t care if your site’s URL contains www. or not; only consistency matters.

    Hi,

    I’m facing the same problem. The native wordpress redirection works fine with W3 off, but when it’s on the http:// to http://www. redirection does not work for all urls. It only works for the main page with the rule:

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

    That is, for http://mysite.com user is redirected correctly to http://www.mysite.com, but for http://mysite.com/mypost, user is not redirected to http://www.mysite.com/mypost, instead the redirection takes him to main page.

    How to fix it Frederick?

    Thanks in advance for such a powerful plugin

    When using disk enhanced mode make sure that the directives appended to that file appear directly above the pretty permalink directives for WordPress. Then move all of the other directives above the W3TC directives and all will be fine. This is better handled in the development version: http://wordpress.org/extend/plugins/w3-total-cache/download/

    I believe the issue is that W3TC doesn’t take into account different host names when it caches pages to disk. As a result, when a request comes in for domain.com, the rewrite rules send out the cached file, which is what makes it fast. The down side is that by bypassing WordPress the canonical URL functionality that would redirect to http://www.domain.com is also bypassed.

    The ideal fix would be to add the host name to the page cache root. Instead of wp-content/w3tc/pgcache/, use wp-content/w3tc/pgcache/{HOSTNAME}/. WP Super Cache does this and it works nicely – requests to domain.com are not served from the cached files for http://www.domain.com, so WordPress gets executed and redirects to the canonical URL, and there is no output to cache.

    Any chance we could see this in W3 Total Cache?

    Thanks!
    John

    There is no reason to use hostname in cache path because http://www.domain.com and domain.com has same content. Redirection rules should be at the top of .htaccess

    Hi Fred,
    I’m also facing the problem with WP-3 and W3TC. I installed the development version and tried as you told in the above conversations. mydomain.com does not redirect to http://www.mydomain.com. But if I disable the home page caching then that works. But the page performance decreases. Any solution?

Viewing 15 replies - 1 through 15 (of 30 total)
  • The topic ‘After W3 Total Cache redirect domain.de to www.domain.de does not work!’ is closed to new replies.
Skip to toolbar