HTTPD配置筆記

  • 將多個域名301重定向至一個域名服務器

  1. 添加訪問域名的DNS記錄,使之能解析至同一服務器;ide

  2. 修改httpd的配置,容許網站目錄下的.htaccess配置覆蓋httpd的配置;網站

  3. 編輯.htaccess,配置重定向域名。ui


Example:使www.oimec.com.cn、www.oimec.cn、www.jicheng.cn 三個域名301重定向至www.jicheng.net.cnspa

<VirtualHost *:80>
    ServerAdmin admin@abc.com
    ServerName www.jicheng.net.cn
    ServerAlias www.jicheng.cn www.oimec.com.cn www.oimec.cn
    DocumentRoot  /data/htdocs/jicheng
<Directory "/data/htdocs/jicheng/">
    Options FollowSymLinks
    AllowOverride All     #啓用網站目錄下的.htaccess,使之生效
    Require all granted
</Directory>
</VirtualHost>
  • 在網站目錄下添加.htaccess文件,內容以下:orm

RewriteEngine On

# www.oimec.com.cn www.oimec.cn www.jicheng.cn redirect to www.jicheng.net.cn
RewriteBase /data/htdocs/jicheng/
RewriteCond %{HTTP_HOST} ^www.oimec.com.cn [OR]
RewriteCond %{HTTP_HOST} ^www.oimec.cn [OR]
RewriteCond %{HTTP_HOST} ^www.jicheng.cn [NC]
RewriteRule ^(.*)$ http://www.jicheng.net.cn/$1 [L,R=301]


驗證:blog

wKioL1jfg-7D6w7fAAHgJcxn2lE566.png

相關文章
相關標籤/搜索