標籤:apache httpd
-
添加訪問網域名稱的DNS記錄,使之能解析至同一伺服器;
-
修改httpd的配置,允許網站目錄下的.htaccess配置覆蓋httpd的配置;
-
編輯.htaccess,配置重新導向網域名稱。
Example:使www.oimec.com.cn、www.oimec.cn、www.jicheng.cn 三個網域名稱301重新導向至www.jicheng.net.cn
<VirtualHost *:80> ServerAdmin [email protected] 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>
RewriteEngine On# www.oimec.com.cn www.oimec.cn www.jicheng.cn redirect to www.jicheng.net.cnRewriteBase /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]
驗證:
650) this.width=650;" src="https://s3.51cto.com/wyfs02/M00/8F/79/wKioL1jfg-7D6w7fAAHgJcxn2lE566.png" title="Image 1.png" alt="wKioL1jfg-7D6w7fAAHgJcxn2lE566.png" />
本文出自 “銀凱的部落格” 部落格,請務必保留此出處http://yinkai.blog.51cto.com/3813923/1912480
HTTPD配置筆記