由于网站需要,把不带www和带www的域名合并到一起,而新网的又没有了转向功能,只能由服务器下手。谷歌知道需要使用301定向。以便将phodal.com转向www.phodal.com。
原来的配置文件如下
server
{
listen 80;
server_name phodal.com www.phodal.com;
index index.html index.htm index.php default.html default.htm default.php;
root /home/wwwroot/onelone.com;
include typecho.conf;
location ~ .*\.(php|php5)?$
{
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;
}
将phodal.com删除再添加
server {
server_name phodal.com;
rewrite ^(.*) http://www.phodal.com$1 permanent;
}
由于最后就如下所示:
(转载请保留;Phodal's 博客)
server
{
listen 80;
server_name www.phodal.com;
index index.html index.htm index.php default.html default.htm default.php;
root /home/wwwroot/onelone.com;
include typecho.conf;
location ~ .*\.(php|php5)?$
{
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;
}server {
server_name phodal.com;
rewrite ^(.*) http://www.phodal.com$1 permanent;
}
分享到:
相关推荐
文档讲述了消除301缓存的方法,并举例说明
详解 Nginx 301重定向的配置 301重定向是很常见的需求,比如访问 nowamagic.net,自动跳到 www.nowamagic.net。或者倒过来,访问 www.nowamagic.net 跳到 nowamagic.net。Nginx 中配置 301 重定向(301 redirect)很...
nginx和Apache下 设置网站301重定向
nginx 301 302重定向跳转配置.docx
主要介绍了nginx url自动加斜杠及301重定向的问题的相关资料,非常不错,具有参考借鉴价值,需要的朋友可以参考下
主要介绍了ngin配置301重定向设置方法和nginx子目录301重定向,需要的朋友可以参考下
nginx 伪静态 重定向
主要介绍了nginx http重定向https配置说明的相关资料,需要的朋友可以参考下
linux中nginx 301重定向跳转方法总结,有需要的朋友可参考一下。 第一种情况:访问aaaaaaa站定向到bbbbbbbbbbb站 代码如下: server { server_naaaaaaame www.aaaaaaa.com ; rewrite ^(.*) ...
1、假设要把webroot/static/index.html访问重定向到static/index.html 例如当我们通过浏览器访问http://192.168.11.210/webroot/static/index.html,实际访问的是web目录下面的static/index.html文件,也及去掉了web...
之前给nginx做301重定向的时候经常会这样写: 代码如下: server { listen 80; server_name www.jb51.net jb51.net; if ($http_host = www.jb51.net) { rewrite (.*) http://jb51.net$1; } … } ...
一、nginx 地址重定向 二、nginx 反向代理 1、地址重定向:是指当使用者浏览某个网址时,将他导向到另一个网址的技术。常用在把一串很长的网址,转成较短的网址。因为当要传播某网站时,常常因为网址太长,不好...
301重定向不陌生, 有时候有需求把某目录整个重定向到一个二级域名,或者不带www的顶级域名请求全部重定向到带www的二级域名.如果是Apache,需要配置.htaccess,nginx不支持,需要在配置文件里面使用rewrite指令来实现...
如果你在处理 Nginx 重定向时要获取原请求的域名(比如 HTTP 到 HTTPS),请用 $host 而不是 $server_name 。 问题和解决方案 今天碰到一个问题,服务器上一个子域名的请求重定向到另一个子域名上面去了。查了一段...
本篇文章主要介绍了详解Nginx几种常见实现301重定向方法上的区别,具有一定的参考价值,感兴趣的小伙伴们可以参考一下