HTTPD配置筆記

來源:互聯網
上載者:User

標籤:apache   httpd   

  • 將多個網域名稱301重新導向至一個網域名稱

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

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

  3. 編輯.htaccess,配置重新導向網域名稱。


Example:使www.oimec.com.cn、www.oimec.cn、www.jicheng.cn 三個網域名稱301重新導向至www.jicheng.net.cn

  • 修改DNS,添加www.oimec.com.cn、www.oimec.cn、www.jicheng.cn網域名稱的CNAME記錄至www.jicheng.net.cn。

  • 修改httpd的設定檔:

<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>
  • 在網站目錄下添加.htaccess檔案,內容如下:

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配置筆記

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.