2012-01-23 19 views

risposta

5

ho trovato questo articolo utile su questo argomento: clean urls in nginx

Scorrere verso il basso per la - sezione per vedere come è fatto facilmente "il tocco finale SEF URL".

Cheers.

+0

Grazie, l'articolo è utile – Joel

+0

Grazie, ha avuto lo stesso problema –

2

In sintesi, è necessario consentire a NGINX di sapere che se il file non esiste, non generare un errore 404, ma chiamare lo index.php. Wordpress è abbastanza intelligente da analizzare l'URL come parametri e servire la pagina corretta.

Aggiungere questo frammento nel blocco di configurazione del server:

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

Ecco un esempio completo da nginx.org:

# Upstream to abstract backend connection(s) for php 
upstream php { 
     server unix:/tmp/php-cgi.socket; 
     server 127.0.0.1:9000; 
} 

server { 
     ## Your website name goes here. 
     server_name domain.tld; 
     ## Your only path reference. 
     root /var/www/wordpress; 
     ## This should be in your http block and if it is, it's not needed here. 
     index index.php; 

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

     location = /robots.txt { 
       allow all; 
       log_not_found off; 
       access_log off; 
     } 

     location/{ 
       # This is cool because no php is touched for static content. 
       # include the "?$args" part so non-default permalinks doesn't break when using query string 
       try_files $uri $uri/ /index.php?$args; 
     } 

     location ~ \.php$ { 
       #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini 
       include fastcgi.conf; 
       fastcgi_intercept_errors on; 
       fastcgi_pass php; 
     } 

     location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ { 
       expires max; 
       log_not_found off; 
     } 
} 
+0

Si noti che "permalink non predefiniti" include anche collegamenti di categoria. Nella mia configurazione iniziale questa riga diceva 'try_files $ uri $ uri/= 404'; sostituire '= 404' con' /index.php? $ args 'era il passaggio necessario per ripristinare il funzionamento dei miei collegamenti di categoria. – rsfinn

Problemi correlati