2012-01-25 38 views

回答

1

试试这个设置:

location/{ 
    rewrite /page/ http://mysite.com/page/index.html permanent; 
    ... 
} 
+0

谢谢。会尝试。包括 ...? – Hayden

+0

尝试过但它不起作用。看看我如何在下面添加代码... – Hayden

+0

目录页面是否存在?尝试在第一行进行重写,然后放置try_files。并且请提供查询示例,如果可能的话 –

1

我从您的评论看到Sergiei了“/page /'目录和'/page/index.html'实际上并不存在,并在别处重写。所以Nginx没有找到404就不足为奇了。

如果访问者请求“/page/index.html”,究竟应该得到什么? I.E.,这些重写是什么?

如果是的index.php Q = /页/ index.html的,那么你的配置应该是:

server { 
    # index directive should be in server or http block 
    # So no need to repeat in every location block 
    # unless specifically overriding it 
    index index.php index.html; 
    location/{ 
     rewrite ^/page(/?)$ /page/index.html break; 
     try_files $uri $uri/ /index.php?q=$uri; 
    } 
} 

你也可以使用

server { 
    index index.php index.html; 
    location/{ 
     try_files $uri $uri/ /index.php?q=$request_uri; 
    } 
} 

但可能会出现一些问题接着就,随即。全部取决于你的应用程序的细节。