凌的博客

您现在的位置是: 首页 > 学无止境 > PHP > 

PHP

.htaccess ,nginx301跳转

2015-07-07 PHP 816
Options +FollowSymlinks RewriteEngine On RewriteCond %{HTTP_HOST} !^www.domain.com$ [NC] RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301] RewriteRule ^http://[^\\/]+\\/(.*)$ http:/






Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.domain.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301]
RewriteRule ^http://[^\/]+\/(.*)$ http://www.domain.com/index.php/$1 [QSA,PT,L]





if ( $host = 'imeipic.com' ) {
    rewrite ^/(.*)$ http://www.imeipic.com/$1 permanent;
}

#注意空格 nginx配置里 变量与变量之间 以及符号必须要有空格 配置比较严格




set $flag  0;

if ( $host != 'www.imeipic.com' ) {
   set $flag 1;
}

if ( $host = 'm.imeipic.com' ) {
   set $flag 2;
}


  if ( $flag = 1 ) {
   rewrite ^/(.*)$ http://www.imeipic.com/$1 permanent;
  }


文章评论

0条评论