[英]Nginx Wordpress Permalinks without index.php
我的Nginx使用php 7 fpm運行。 我的Wordpress永久鏈接是使用/%postname%/
。 假設我的域名是example.com
我想要這樣的永久鏈接: example.com/postname/
但這會導致錯誤。 我可以通過以下鏈接找到該帖子: example.com/index.php?postname/
如何擺脫index.php?
在鏈接中?
我的Nginx配置
server {
server_name localhost;
root /var/www/;
index index.html index.htm index.php;
location ~\.php$ {
try_files $uri =404;
fastcgi_pass php:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_param REQUEST_URI $args;
}
location / {
try_files $uri $uri/ /index.php$args;
}
location /wordpress/ {
try_files $uri $uri/ /wordpress/index.php?$args;
}
}
您的問題暗示WordPress安裝在location /
,所以我不確定為什么您也有location /wordpress
。
您的配置存在一些問題。
REQUEST_URI的值應設置為$request_uri
,這可能已經是fastcgi_params
文件中的默認值。 這是index.php
用於解碼漂亮的永久鏈接的參數。
刪除行fastcgi_param REQUEST_URI $args;
。
您的try_files
語句缺少?
。 使用以下任一方法:
try_files $uri $uri/ /index.php?$args;
要么:
try_files $uri $uri/ /index.php;
我發現使用WordPress不需要將$args
傳遞到/index.php
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.