开发者社区> 问答> 正文

nginx禁止IP访问和301定向的问题。


server {
        server_name www.123.com 123.com ;
if ($host != 'www.123.com' ) {
rewrite ^/(.*)$ http://www.123.com/$1 permanent;
}
    index index.html index.htm index.php;
    root /alidata/www/default;
      
    location ~ .*\.(php|php5)?$
    {
        #fastcgi_pass  unix:/tmp/php-cgi.sock;
        fastcgi_pass  127.0.0.1:9000;
        fastcgi_index index.php;
        include fastcgi.conf;
    }


按网上的教程改的,
我想把不带www的指向带www的,就是123.com  301到www.123.com.
但是现在www.123.com返回状态码也变成了301
请问这是怎么回事?

展开
收起
noxun888 2014-06-10 16:18:00 9606 0
2 条回答
写回答
取消 提交回答
  • 回1楼服务器之家的帖子
    www.123.com返回状态码不应该是200吗?

    -------------------------

    Renginx禁止IP访问和301定向的问题。
    返回状态码:301
    网页返回HEAD信息如下
    Server: nginx/1.4.7
    Date: Tue, 10 Jun 2014 08:25:22 GMT
    Content-Type: text/html
    Transfer-Encoding: chunked
    Connection: keep-alive
    X-Powered-By: PHP/5.4.27
    location: forum.php

    -------------------------

    回4楼服务器之家的帖子
    请问怎么才能返回200呢?

    -------------------------

    回5楼服务器之家的帖子
    明白了,谢谢
    2014-06-10 16:24:05
    赞同 展开评论 打赏
  • 从你帖的内容来看没有问题

    -------------------------

    我说的是你帖的配置文件内容

    -------------------------

    访问首页跳转到forum.php,这是DZ默认的设置。

    -------------------------

    Discuz X3去除首页跳转到forum.PHP的方法

    2014-06-10 16:22:18
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
《Nginx 代理系统常用手册》 立即下载
CentOS Nginx PHP JAVA 多语言镜像使用手 立即下载
CentOS Nginx PHP JAVA多语言镜像使用手册 立即下载