WordPress.org

Ready to get started?Download WordPress

Forums

W3 Total Cache
Redirects not working after including nginx.conf (1 post)

  1. Ryan Burnette
    Member
    Posted 4 months ago #

    My existing location block looks like this. It's tested and working.

    location / {
      rewrite ^/wp-content(.*)$ /wordpress/wp-content$1 permanent;
    }

    After including the plugin-generated nginx.conf, my redirect stops working. Here's the content of that file.

    # BEGIN W3TC Page Cache cache
    location ~ /wordpress/wp-content/cache/page_enhanced.*html$ {
        add_header Vary "Accept-Encoding, Cookie";
        add_header Pragma "public";
        add_header Cache-Control "max-age=3600, public";
    }
    location ~ /wordpress/wp-content/cache/page_enhanced.*gzip$ {
        gzip off;
        types {}
        default_type text/html;
        add_header Vary "Accept-Encoding, Cookie";
        add_header Pragma "public";
        add_header Cache-Control "max-age=3600, public";
        add_header Content-Encoding gzip;
    }
    # END W3TC Page Cache cache
    # BEGIN W3TC Browser Cache
    gzip on;
    gzip_types text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon;
    location ~ \.(css|htc|less|js|js2|js3|js4)$ {
        add_header Pragma "public";
        add_header Cache-Control "max-age=31536000, public";
    }
    location ~ \.(html|htm|rtf|rtx|svg|svgz|txt|xsd|xsl|xml)$ {
        add_header Pragma "public";
        add_header Cache-Control "max-age=3600, public";
    }
    location ~ \.(asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|eot|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|json|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|otf|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|tif|tiff|ttf|ttc|wav|wma|wri|woff|xla|xls|xlsx|xlt|xlw|zip)$ {
        add_header Pragma "public";
        add_header Cache-Control "max-age=31536000, public";
    }
    # END W3TC Browser Cache
    # BEGIN W3TC Page Cache core
    set $w3tc_rewrite 1;
    if ($request_method = POST) {
        set $w3tc_rewrite 0;
    }
    if ($query_string != "") {
        set $w3tc_rewrite 0;
    }
    if ($request_uri !~ \/$) {
        set $w3tc_rewrite 0;
    }
    if ($http_cookie ~* "(comment_author|wp\-postpass|w3tc_logged_out|wordpress_logged_in|wptouch_switch_toggle)") {
        set $w3tc_rewrite 0;
    }
    if ($http_cookie ~* "(w3tc_preview)") {
        set $w3tc_rewrite _preview;
    }
    set $w3tc_enc "";
    if ($http_accept_encoding ~ gzip) {
        set $w3tc_enc _gzip;
    }
    if (!-f "$document_root/wordpress/wp-content/cache/page_enhanced/$http_host/$request_uri/_index$w3tc_rewrite.html$w3tc_enc") {
      set $w3tc_rewrite 0;
    }
    if ($w3tc_rewrite = 1) {
        rewrite .* "/wordpress/wp-content/cache/page_enhanced/$http_host/$request_uri/_index$w3tc_rewrite.html$w3tc_enc" last;
    }
    # END W3TC Page Cache core

    I'm sure that one of the generated location blocks is causing the issue. Any advice is appreciated.

    https://wordpress.org/plugins/w3-total-cache/

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.