- Trạng thái
- Đã được giải quyết bởi nhà phát triển
- Plugin/giao diện liên quan
- Custom Permalinks
- Thẻ chủ đề
- Compatibility
Tổng quan về lỗi
Khi sử dụng plugin Custom Permalinks, bạn có thể gặp phải các chuyển hướng 301 không cần thiết khi truy cập các URL có dấu gạch chéo ở cuối.
Giải pháp tạm thời
Vui lòng đảm bảo có một bản sao lưu toàn bộ trang web của bạn trước khi tiếp tục.
- Mở tệp …/wp-content/plugins/custom-permalinks/includes/class-custom-permalinks-frontend.php.
- Thay thế:
// Append any query compenent. $url .= strstr( $this->request_uri, '?' ); wp_safe_redirect( home_url() . '/' . $url, 301 ); exit( 0 ); } }
- Bằng:
// 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 ); } }