【发布时间】:2016-05-22 22:24:27
【问题描述】:
我正在尝试在我的 wordpress 安装中激活漂亮的永久链接,但没有成功。我正在更改此文件 /etc/nginx/conf.d/default.conf
我尝试了以下方法:
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; -
你阅读过关于使用 nginx 的 WordPress 文档吗?codex.wordpress.org/Nginx
-
Arcesilas,也试过了,但没有成功。 Moshe Katz,是的,我读过它,但我不知道为什么我的文件有问题:(
标签: php wordpress nginx centos7