我刚刚将我的webste移动到另一台服务器,在安装了nginx + php5-fpm后,我发现了一个奇怪的固定链接结构。服务器名称在永久链接结构中重复。
示例:
www.myserver.com/myserver.com/%postname %%天%% monthnum% 这些是重写规则我想使用wordpress显示我添加到.htaccess(我不能使用,因为它是nginx。)在RewriteBase中有这个错误,我相信它应该只是一个“/”“那里,而不是它告诉我:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /myserver.com/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /myserver.com/index.php [L]
</IfModule>
我的nginx.conf看起来像这样:
user www-data;
worker_processes 4;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 2;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
#access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
access_log off;
client_max_body_size 128M;
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/css text/javascript text/xml text/plain text/x-component application/javascript application/x-javascript application/json application/xml application/rss+xml font/truetype application/x-font-ttf font/opentype application/vnd.ms-fontobject image/svg+xml;
##
# Virtual Host Configs
##
index index.php;
## See here: http://wiki.nginx.org/WordPress
server {
## Your IP number goes here:
listen XXX.XXX.XXX.XXX;
rewrite ^/wp-content/w3tc/min/([a-f0-9]+)\/(.+)\.(include(\-(footer|body))?(-nb)?)\.[0-9]+\.(css|js)$ /wp-content/w3tc/min/index.php?tt=$1&gg=$2&g=$3&t=$7 last;
## Your website name goes here.
server_name myserver.com;
## Your only path reference.
root /var/www/myserver.com;
location /phpmyadmin {
root /usr/share/;
index index.php index.html index.htm;
location ~ ^/phpmyadmin/(.+\.php)$ {
try_files $uri =404;
root /usr/share/;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
root /usr/share/;
}
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location / {
# This is cool because no php is touched for static content
try_files $uri $uri/ /index.php;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
}
}
答案 0 :(得分:0)
Wordpress检查Apache mod_rewrite,WP需要它与永久链接正常工作,dixit codex
如果你想让它更有效,可以使用Nginx_helper插件,你可以在这里找到它:https://wordpress.org/extend/plugins/nginx-helper/
在之前链接的codex中,您将找到使Wordpress与Nginx一起使用所需的所有配置文件!
希望它有所帮助!