0

我的固定鏈接是~~/%category%~~/%postname%/~~.html~~。 我從Apache遷移到Nginx。 然後我的配置文件我在移植到Nginx後的Wordpress固定鏈接

server{ 
location /mydirectory/ { 
    try_files $uri $uri/ /mydirectory/$uri.html; 
} 

添加,但我的瀏覽器繼續將404頁。 我試圖刪除緩存,但仍然沒有success.Any幫助將非常感激 後發現有很多代碼謝謝

我desactivate我所有的插件,並能夠改變我的永久鏈接到

/%postname%/

這裏是我的my.site.com配置(我的網站是一個子目錄的Vie /):

server { 
listen 80; 
server_name my.site.com; 
location ~ /(vie|\|Vie|Vie)/(.*) { 
return 301 https://my.site.com/Vie; 
} 
return 301 https://my.site.com/Vie$request_uri; 
} 

server { 
    listen 443 ssl; 
server_name my.site.com; 
root /var/www/my.site.com/html; 
index index.php index.html; 

ssl_certificate /etc/letsencrypt/live/krouus.company/fullchain.pem; 
ssl_certificate_key /etc/letsencrypt/live/krouus.company/privkey.pem; 

ssl_protocols TLSv1 TLSv1.1 TLSv1.2; 

ssl_prefer_server_ciphers on; 
ssl_ciphers 'DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-CAMELLIA256-SHA:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES256-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-CAMELLIA128-SHA:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES128-SHA256'; 

ssl_session_cache shared:SSL:10m; 
ssl_session_timeout 10m; 


ssl_dhparam /etc/nginx/dhparam.pem; 


add_header Strict-Transport-Security "max-age=31536000;"; 

location /Vie/ { 
index index.php; 
    try_files $uri $uri/ /Vie/index.php?$args; 
} 


location/{ 
    try_files $uri $uri/ /Vie/index.php; 
    fastcgi_split_path_info ^(.+\.php)(/.+)$; 
    fastcgi_pass unix:/run/php/php7.0-fpm.sock; 
    fastcgi_index index.php; 
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
     include fastcgi_params; 
     fastcgi_intercept_errors on; 
     fastcgi_ignore_client_abort off; 
     fastcgi_connect_timeout 60; 
     fastcgi_send_timeout 180; 
     fastcgi_read_timeout 180; 
     fastcgi_buffers 4 256k; 
     fastcgi_buffer_size 128k; 
     fastcgi_busy_buffers_size 256k; 
     fastcgi_temp_file_write_size 256k; 
} 
    location ~ \.php$ { 
    include snippets/fastcgi-php.conf; 
      include fastcgi_params; 
     fastcgi_pass unix:/run/php/php7.0-fpm.sock; 
      fastcgi_param SCRIPT_FILENAME  
    $document_root$fastcgi_script_name; 
} 


    location ~* commun { 
     deny all; 
} 


location = /favicon.ico { 
    log_not_found off; 
    access_log off; 
} 

location = /robots.txt { 
    allow all; 
    log_not_found off; 
    access_log off; 
} 
    location ~ /\.ht { 
    deny all; 
} 
location ~ (^|/)\. { 
    return 403; 
} 
     location ~* \.(?:css|gif|htc|ico|js|jpe?g|png|swf)$ { 
     expires max; 
     log_not_found off; 
     ## No need to bleed constant updates. Send the all shebang in one 
     ## fell swoop. 
     tcp_nodelay off; 
     ## Set the OS file cache. 
     open_file_cache max=1000 inactive=120s; 
     open_file_cache_valid 45s; 
     open_file_cache_min_uses 2; 
     open_file_cache_errors off; 
    } 
location ~* \.ini$ { 
    deny all; 
    return 404; 
} 
    error_page 404 /404.html; 
     location /404.html { 
     internal; 
    } 

    location ~* /(?:uploads|files)/.*\.(html|htm|shtml|php|js|swf|py|jsp|asp|sh|cgi)$ { 
    deny all; 
    } 
    if ($request_method !~ ^(GET|POST|HEAD)$) { 
    return 444; 
    } 

    location ~* wp-includes/theme-compat/ { 
    deny all; 
    } 

location ~* wp-includes/js/tinymce/langs/.*.php { 
    deny all; 
} 

location /wp-includes/ { 
internal; 
} 
location ~* .(pl|cgi|py|sh|lua|asp)$ { 
    return 444; 
    } 
location ~* /(wp-config.php|readme.html|license.txt|nginx.conf) { 
    deny all; 
    } 


if (!-e $request_filename) { 
rewrite ^.*$ /index.php last; 
} 

location /xmlrpc.php { 
deny all; 
} 
} 

回答

0

試試這個。因爲我也面臨同樣的問題,所以也希望它也適合你。

location /mydirectory{ 
    try_files $uri $uri/ /mydirectory/index.php; 
} 
+0

謝謝bdspice,但我仍然有404結果... –

0

事實上,我解決了我的問題。我仔細閱讀我的配置和刪除

if (!-e $request_filename) { 
rewrite ^.*$ /index.php last; 
} 

現在我的WordPress的作品。

Cheerio!