求助,搞不定二级目录下Wordpress的伪静态,求军哥指点迷津,
如何,试过了好多方法,实在不知道二级目录下的Wordpress博客的伪静态处理方法。把配置文件贴出来,求大神指点一下,看问题出在哪里?可以正常访问xxx.com/blog/,但是下面的文章就会出现404错误:
我的网站目录:
/home/wwwroot/xxx:
WP Blog目录:
/home/wwwroot/xxx/blog
Nginx.conf文件:userwww www;
worker_processes 1;
error_log/home/wwwlogs/nginx_error.logcrit;
pid /usr/local/nginx/logs/nginx.pid;
#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 51200;
events
{
use epoll;
worker_connections 51200;
}
http
{
include mime.types;
default_typeapplication/octet-stream;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 50m;
sendfile on;
tcp_nopush on;
keepalive_timeout 60;
tcp_nodelay on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 256k;
gzip on;
gzip_min_length1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;
gzip_proxied expired no-cache no-store private auth;
gzip_disable "MSIE \.";
#limit_zonecrawler$binary_remote_addr10m;
server_tokens off;
#log format
log_formataccess'$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" $http_x_forwarded_for';
server
{
listen 80;
server_name www.xxx.com;
index index.html index.htm index.php;
root/home/wwwroot/xxx;
#include wordpress.conf;
location ~ .*\.(php|php5)?$
{
try_files $uri =404;
fastcgi_passunix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fcgi.conf;
}
location /status {
stub_status on;
access_log off;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
access_log/home/wwwlogs/access.logaccess;
}
include vhost/*.conf;
}vhost/xxx.conf文件:server
{
listen 80;
server_name www.xxx.com xxx.com;
index index.html index.htm index.php default.html default.htm default.php;
root/home/wwwroot/xxx;
include wp2.conf;
location ~ .*\.(php|php5)?$
{
try_files $uri =404;
fastcgi_passunix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fcgi.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
access_log off;
}WP2.conf文件:location /blog/ {
if (-f $request_filename/index.html){
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php){
rewrite (.*) $1/index.php;
}
if (!-f $request_filename){
rewrite (.*) /blog/index.php;
}
}
以上失败,求解决方法! 期间试过一下N种方法,均以失败告终:
1. 方法1
location / {
rewrite ^/blog/wp-admin$ /blog/wp-admin/ permanent;
if (-f $request_filename/index.html){
rewrite ^/blog/(.*) /blog/$1/index.html break;
}
if (-f $request_filename/index.php){
rewrite ^/blog/(.*) /blog/$1/index.php;
}
if (!-f $request_filename){
rewrite ^/blog/(.*) /blog/index.php;
}
}
2. 方法2:
location /blog/{
rewrite ^/wp-admin$ /wp-admin/ permanent;
if (-f $request_filename/index.html){
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php){
rewrite (.*) $1/index.php;
}
if (!-f $request_filename){
rewrite (.*) /blog/index.php;
}
}
3. 方法3:
location /blog/ {
try_files $uri $uri/ /blog/index.php?q=$uri&$args;
} 顶起来,继续求答案 wp2.conf 的就是没问题的
你自己看看wp2.conf的源文件是什么,你改错了
回复 4# 的帖子
军哥,没错啊,实在找不到出错原因 wp2.conf原文件如下:location /wp {
if (-f $request_filename/index.php) {
rewrite (.*) $1/index.php;
}
if (!-f $request_filename){
rewrite ^/wp/(.*)$ /wp/index.php;
}
}
wp替换为对应的目录,你自己看看你怎么改的对比一下就知道了
回复 6# 的帖子
换了,还是没用....仍然是404
回复 6# 的帖子
server { listen 80; server_name www.xxxx.com xxx.com; index index.html index.htm index.php default.html default.htm default.php;root /home/wwwroot/xxxx;
include wp2.conf; location ~ .*\.(php|php5)?$ { try_files $uri =404; fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_index index.php; include fcgi.conf; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~ .*\.(js|css)?$ { expires 12h; } access_log off; }location /blog { if (-f $request_filename/index.php) { rewrite (.*) $1/index.php; } if (!-f $request_filename){ rewrite ^/blog/(.*)$ /blog/index.php; } }军哥,你看
换了,还是没用....
仍然是404
[ 本帖最后由 Frank 于 2014-1-16 23:20 编辑 ]
页:
[1]