我想激活我wordpress安裝上的漂亮鏈接,但沒有成功。我改變了這個文件/etc/nginx/conf.d/default.confNGINX for Wordpress上的漂亮鏈接 - CentOS 7
我試過如下:
server{
if (!-e $request_filename) { rewrite ^.*$ /index.php last;
server {
if ($host ~* ^myhost\.com$) {
rewrite ^(.*) http://www.myhost.com$1 permanent;
break;
}
location/{
try_files $uri $uri/ /index.php?q=$request_uri;
}
但這些都沒有工作:(這是我的完整文件:
server {
listen 80;
server_name example.com;
return 301 http://www.example.com$request_uri;
}
server {
listen 80;
server_name www.example.com;
note that these lines are originally from the "location /" block
root /usr/share/nginx/html;
index index.php index.html index.htm;
location/{
root /usr/share/nginx/html;
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?$args;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
你能幫助我嗎?
非常感謝。
'try_files $ URI $ URI//index.php?$ args;' – Arcesilas
另外:https://www.nginx.com/resources/wiki/start/topics/recipes/wordpress/ – Arcesilas
有你讀過關於使用nginx的WordPress文檔?https://codex.wordpress.org/Nginx –