דלג על הניווט

Waiting for author

Topic Tags: Compatibility

Overview of the issue

When using the the Custom Permalinks plugin, you may experience unnecessary 301 redirects when accessing URLs with a trailing slash.

Workaround

Please, make sure of having a full site backup of your site before proceeding.

  • Open the …/wp-content/plugins/custom-permalinks/includes/class-custom-permalinks-frontend.php file.
  • Replace:
    			// Append any query compenent.
    			$url .= strstr( $this->request_uri, '?' );
    
    			wp_safe_redirect( home_url() . '/' . $url, 301 );
    			exit( 0 );
    		}
    	}
    
  • With:
    			// Append any query compenent.
    			$url .= strstr( $this->request_uri, '?' );
    			$home_url = home_url();
    			if (substr($home_url, -1) == '/'){
    				wp_safe_redirect( $home_url . $url, 301 );
    			} else {
    				wp_safe_redirect( $home_url . '/' . $url, 301 );
    			}
    			exit( 0 );
    		}
    	}
    

השאר תגובה

אנא הישאר בנושא והיה מכבד כלפי אחרים. אם אתה זקוק לעזרה בנושאים שאינם קשורים לפוסט זה, השתמש בפורום התמיכה שלנו כדי להתחיל צ'אט או לשלוח כרטיס.

אתה יכול להשתמש בתגים אלה:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>