为nginx重写wordpress 3.0(多站点)规则?

发布于 2024-08-22 13:08:13 字数 648 浏览 4 评论 0原文

这是 WordPress 使用的新版本...

RewriteEngine On
RewriteBase BASE/

#uploaded files
RewriteRule ^(.*/)?files/$ index.php [L]
RewriteCond %{REQUEST_URI} !.*wp-content/plugins.*
RewriteRule ^(.*/)?files/(.*) wp-includes/ms-files.php?file=$2 [L]

# add a trailing slash to /wp-admin
RewriteCond %{REQUEST_URI} ^.*/wp-admin$
RewriteRule ^(.+)$ $1/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule . - [L]
RewriteRule  ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule  ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]

它在 Nginx 中会是什么样子?

This is the new version being used by wordpress...

RewriteEngine On
RewriteBase BASE/

#uploaded files
RewriteRule ^(.*/)?files/$ index.php [L]
RewriteCond %{REQUEST_URI} !.*wp-content/plugins.*
RewriteRule ^(.*/)?files/(.*) wp-includes/ms-files.php?file=$2 [L]

# add a trailing slash to /wp-admin
RewriteCond %{REQUEST_URI} ^.*/wp-admin$
RewriteRule ^(.+)$ $1/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule . - [L]
RewriteRule  ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule  ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]

What would it look like in Nginx?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

逆光飞翔i 2024-08-29 13:08:14

这取决于您想如何使用 WordPress 多站点。

对于带有子域的多站点 - http://rtcamp.com/tutorials/nginx -wordpress-multisite-subdomains-domain-mapping/

对于带有子目录的多站点 - http://rtcamp.com/tutorials/wordpress-nginx-multisite-subdirectories-nginx-map/

您将需要根据您计划使用的缓存插件/机制添加更多规则。 (参考)

It depends how do you want to use WordPress Multisite.

For Multisite with Subdomain - http://rtcamp.com/tutorials/nginx-wordpress-multisite-subdomains-domain-mapping/

For Multisite with Subdirectory - http://rtcamp.com/tutorials/wordpress-nginx-multisite-subdirectories-nginx-map/

You will need to add some more rules depending on which cache plugin/mechanism you plan to use. (ref)

古镇旧梦 2024-08-29 13:08:13
location / {
 root   /your/document/root;
 index  index.html index.htm index.php;
 if (!-e $request_filename) {
        rewrite ^.+/?(/wp-.*) $1 last;
        rewrite ^.+/?(/.*\.php)$ $1 last;
        rewrite ^(.+)$ /index.php?q=$1 last;
        }
 }

 location ~* ^.+\.(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js)$
        {
        root /your/document/root;
        rewrite ^/.*(/wp-.*/.*\.(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js))$ $1 last;

        rewrite ^.*/files/(.*(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js))$/wp-includes/ms-files.php?file=$1 last;
        expires 30d;
        break;
        }
location / {
 root   /your/document/root;
 index  index.html index.htm index.php;
 if (!-e $request_filename) {
        rewrite ^.+/?(/wp-.*) $1 last;
        rewrite ^.+/?(/.*\.php)$ $1 last;
        rewrite ^(.+)$ /index.php?q=$1 last;
        }
 }

 location ~* ^.+\.(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js)$
        {
        root /your/document/root;
        rewrite ^/.*(/wp-.*/.*\.(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js))$ $1 last;

        rewrite ^.*/files/(.*(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js))$/wp-includes/ms-files.php?file=$1 last;
        expires 30d;
        break;
        }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文