2013-04-04 182 views
0

几乎所有关于nginx的主题后& WP漂亮的永久链接我stucked:/nginx的WordPress的漂亮永久链接

这里是我的我的测试WP站点配置(我的DNS正在更新,所以我还没有一个尚未):

# W3TC config rules based on http://elivz.com/blog/single/wordpress_with_w3tc_on_nginx/ 
server { 
    listen 80; ## listen for ipv4; this line is default and implied 
    #listen [::]:80 default ipv6only=on; ## listen for ipv6 
    # Tell nginx to handle requests for the www.orpheecole.com domain 
    server_name   localhost; 
    index    index.php index.html index.htm; 
    root    /var/www/test_wp; 
    access_log   /var/log/nginx/testWp_access.log; 
    error_log   /var/log/nginx/testWp_error.log; 
    # Use gzip compression 
    # gzip_static  on; # Uncomment if you compiled Nginx using --with-http_gzip_static_module 
    gzip    on; 
    gzip_disable  "msie6"; 
    gzip_vary   on; 
    gzip_proxied  any; 
    gzip_comp_level  5; 
    gzip_buffers  16 8k; 
    gzip_http_version 1.0; 
    gzip_types   text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript image/png image/gif image/jpeg; 
    # Rewrite minified CSS and JS files 
    rewrite ^/wp-content/w3tc/min/([a-f0-9]+)\/(.+)\.(include(\-(footer|body))?(-nb)?)\.[0-9]+\.(css|js)$ /wp-content/w3tc/min/index.php?tt=$1&gg=$2&g=$3&t=$7 last; 
    # Set a variable to work around the lack of nested conditionals 
    set $cache_uri $request_uri; 
    # POST requests and urls with a query string should always go to PHP 
    if ($request_method = POST) { 
     set $cache_uri 'no cache'; 
    } 
    if ($query_string != "") { 
     set $cache_uri 'no cache'; 
    } 
    # Don't cache uris containing the following segments 
    if ($request_uri ~* "(\/wp-admin\/|\/xmlrpc.php|\/wp-(app|cron|login|register|mail)\.php|wp-.*\.php|index\.php|wp\-comments\-popup\.php|wp\-links\-opml\.php|wp\-locations\.php)") { 
     set $cache_uri "no cache"; 
    } 
    # Don't use the cache for logged in users or recent commenters 
    if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp\-postpass|wordpress_logged_in") { 
     set $cache_uri 'no cache'; 
    } 
    # similar to Apache Status - handy for quickly checking the health of nginx 
    location /nginx_status { 
       stub_status on; 
       access_log off; 
       allow all; 
    } 
    # Use cached or actual file if they exists, otherwise pass request to WordPress 
    location/{ 
     try_files /wp-content/w3tc/pgcache/$cache_uri/_index.html $uri $uri/ /index.php?$args; 
    } 
    # Cache static files for as long as possible - removed xml as an extension to avoid problems with Yoast WordPress SEO plugin which uses WP rewrite API. 
    location ~* \.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ { 
     try_files  $uri =404; 
     expires   max; 
     access_log  off; 
    } 
    # Deny access to hidden files 
    location ~* /\.ht { 
     deny   all; 
     access_log  off; 
     log_not_found off; 
    } 
    # Pass PHP scripts on to PHP-FPM 
    include global/php-fpm.conf; 
    location ~* \.php$ { 
     fastcgi_index index.php; 
     fastcgi_pass php5-fpm-sock; 
     include   fastcgi_params; 
     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
     fastcgi_param SCRIPT_NAME  $fastcgi_script_name; 
     include /etc/nginx/fastcgi_params; 
    } 
} 

这里是包含在每一个我的网站

# PHP scripts -> PHP-FPM server listening on 127.0.0.1:9000 
location ~ \.php$ { 
    # The following line prevents malicious php code to be executed through some uploaded file (without php extension, like image) 
    # This fix shoudn't work though, if nginx and php are not on the same server, other options exist (like unauthorizing php execution within upload folder) 
    # More on this serious security concern in the "Pass Non-PHP Requests to PHP" section, there http://wiki.nginx.org/Pitfalls 
    try_files $uri =404; 

    # PHP 
    # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini 
    #fastcgi_pass 127.0.0.1:9000; 
    fastcgi_pass php5-fpm-sock; 
    fastcgi_index index.php; 
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
    include fastcgi_params; 
    fastcgi_param QUERY_STRING  $query_string; 
    fastcgi_param REQUEST_METHOD $request_method; 
    fastcgi_param CONTENT_TYPE  $content_type; 
    fastcgi_param CONTENT_LENGTH $content_length; 
    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_buffers 256 16k; 
    #fastcgi_buffer_size 16k; 
    fastcgi_busy_buffers_size 256k; 
    fastcgi_temp_file_write_size 256k; 
} 

在WP我已经安装了nginx的辅助插件,但没有任何变化,只要我开关(t)的“全球”的文件Ø漂亮的永久链接每一个岗位&类返回404错误

+0

我是仍然试图弄清楚这一点:http://stackoverflow.com/questions/23645386/how-to-install-wordpress-alongside-laravel-on-nginx-with-pretty-permalinks-seo – Ryan 2014-05-14 16:51:54

回答

2

确定问题解决了,这里是什么救了我^^

添加下服务器{指令

if ($host ~* ^myhost\.com$) { 
    rewrite ^(.*) http://www.myhost.com$1 permanent; 
    break; 
} 
+0

这是根据'服务器{'config?当寻找答案时,会对其他人有所帮助。 ^^ – Jon 2013-04-23 09:00:18

+1

回答编辑:) – kitensei 2013-04-23 09:23:01

+0

令人敬畏的,未来的搜索者与这个问题,谢谢你,当他们终于找到这个答案。 = d – Jon 2013-04-23 09:25:03

1

内部服务器以下{您的域名nginx配置文件

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