apache and nginx 301重定向

apache and nginx 301重定向

apache

  1. 虚拟主机配置

     <VirtualHost *:80>
     ServerName sw.com
     DocumentRoot "g:/wamp64/www/sw"
     <Directory  "g:/wamp64/www/sw/">
     Options +Indexes +Includes +FollowSymLinks +MultiViews
     AllowOverride All
     Require local
     </Directory>
     </VirtualHost>
    
  2. g:/wamp64/www/sw 目录下 .htaccess文件配置

     <ifmodule mod_rewrite.c>
         RewriteEngine On
         RewriteCond %{HTTP_HOST} www.sw.com$ [NC]
         RewriteRule ^(.*)$ http://sw.com/$1 [L,R=301]
     </ifmodule>
    

现在是 www.sw.com 301重定向到 sw.com

apache conf

nginx conf

标签: nginx

添加新评论