After the Nginx server WordPress multi-site is pseudo-static, the pictures in the picture folder under the site root directory cannot be displayed.

888u

Last update at :2024-07-06,Edit by888u

Due to DedeCMS charges, the original website was migrated to WordPress through the "DedeCMS automatic migration to WordPress plug-in" shared by the "I Love Boiled Fish" blog, which perfectly kept the article ID and URL unchanged. seamless migration. However, during the actual visit, I found that the pictures in the article could not be displayed.

The first thing that comes to mind is to copy the uploads folder of the original DedeCMS website and place it in the root directory of the WordPress website.

But the picture still cannot be displayed when accessing again. At this time, the pictures have been copied and the path is correct.

After careful investigation, it turned out that there was a problem with the pseudo-static rules of WordPress multi-site mode on Nginx.

rewrite ^/([_0-9a-zA-Z-]+/)?wp-admin$ /$1wp-admin/ permanent;
rewrite ^/([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) /$2 last;
rewrite ^/([_0-9a-zA-Z-]+/)?(.*.php)$ /$2 last;
rewrite /. /index.php last;

The last pseudo-static rule above will match all paths in the root directory and be rewritten after index.php. This will cause /uploads/* to be rewritten to index.php/uploads/*. The path is wrong and of course the picture cannot be displayed.

It is easy to solve the problem once you know it. Nginx provides -e to determine whether the file or directory actually exists and the break statement to terminate the matching. Just add the following red code before the last line of the pseudo-static rule.

rewrite ^/([_0-9a-zA-Z-]+/)?wp-admin$ /$1wp-admin/ permanent;
rewrite ^/([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) /$2 last;
rewrite ^/([_0-9a-zA-Z-]+/)?(.*.php)$ /$2 last;
if (-e $request_filename){
break;
}
rewrite /. /index.php last;

Recommended site search: icp registration query network, network server rental, private server website space, Hong Kong vps cloud server, server space, free website application domain name, US multi-ip station group vps, Hong Kong high-defense server, foreign vps, server fees ,

After the Nginx server WordPress multi-site is pseudo-static, the pictures in the picture folder under the site root directory cannot be displayed.

All copyrights belong to 888u unless special state
取消
微信二维码
微信二维码
支付宝二维码