2016-05-22 2 views
2

私は私のwordpressのインストールでかなりのpermalinksを有効にしようとしていますが、成功しません。私は、私は次のことを試してみましたWordpressのためのNGINX - CentOS 7のかなりPermlinks

/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; 
     } 
    } 

お願いします。

ありがとうございます。

+1

'try_files $ URI $ uriのを試してみてください/ /index.php?$ args; ' – Arcesilas

+2

:https://www.nginx.com/resources/wiki/start/topics/recipes/wordpress/ – Arcesilas

+0

ありあなたはnginxを使用してワードプレスのドキュメントを読む?https://codex.wordpress.org/Nginx –

答えて

1
server { 
    listen  80; 
    server_name your-domain.com www.your-domain.com; 

    root /usr/share/nginx/html/your-wp-root-dir; 
    index index.php index.html index.htm; 

    location/{ 
     try_files $uri $uri/ /index.php?q=$request_uri; 
    } 
    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; 
    } 
} 

default.confファイル(sudo /etc/init.d/nginx restart)を更新した後、あなたのnginxサーバを再起動することを忘れないでください

+0

サーク、助けてくれてありがとう、しかしこれはうまくいきませんでした:( これは私を夢中にさせています。私が何か間違っているように見えることは分かっていますが、私は一歩一歩をたどっていますが、このことはうまくいかないのです。 – GOKULUFFYZORO

0

それは少し遅れている、

location/{ 
    try_files $uri $uri/ /index.php?q=$uri$args; 
} 
関連する問題