Home > php教程 > php手册 > body text

apache 配置多个域名和二级域名绑定

WBOY
Release: 2016-06-06 20:01:15
Original
2124 people have browsed it

1.在httpd.conf中设置: ServerName 110.110.110.000 #其中IP就是你申请的IP NameVirtualHost 110.110.110.000 2.配置域名和二级域名 #实现二级域名 IfModule mod_rewrite.c RewriteMap lowercase int:tolower RewriteMap vhost txt: /kncms/vhost.map #内容

 

1.在httpd.conf中设置:

ServerName 110.110.110.000  #其中IP就是你申请的IP
NameVirtualHost 110.110.110.000

2.配置域名和二级域名

 

 #实现二级域名


RewriteMap lowercase int:tolower
RewriteMap vhost txt:/kncms/vhost.map #内容在后面
RewriteCond ${lowercase:%{SERVER_NAME}} ^(.+)$
RewriteCond ${vhost:%1} ^(/.*)$
RewriteRule ^/(.*)$ %1/$1


其中 DocumentRoot 表示程序存放的磁盘路径。
ServerName  表示域名


  DocumentRoot /cms/ 
  ServerName   域名


  DocumentRoot /cms/
  ServerName   一级域名.com


  DocumentRoot /cms/discuz/
  ServerName   bbs.一级域名.com  #二级域名 必须有顶级域名才能有二级域名 

 

#静态页实现跳转

RewriteEngine On
RewriteRule ^(.*)/archiver/((fid|tid)-[/w/-]+/.html)$ $1/archiver/index.php?$2
RewriteRule ^(.*)/forum-([0-9]+)-([0-9]+)/.html$ $1/forumdisplay.php?fid=$2&page=$3
RewriteRule ^(.*)/thread-([0-9]+)-([0-9]+)-([0-9]+)/.html$ $1/viewthread.php?tid=$2&extra=page/%3D$4&page=$3
RewriteRule ^(.*)/space-(username|uid)-(.+)/.html$ $1/space.php?$2=$3

 


  DocumentRoot /kncms/uchome/
  ServerName   home.edukn.com

RewriteEngine On
RewriteRule /(space|network)/-(.+)/.html$ /$1.php?rewrite=$2 [L]
RewriteRule /(space|network)/.html$ /$1.php [L]
RewriteRule /([0-9]+)$ /space.php?uid=$1 [L]

 

 

 

vhost.map 内容

 

www.edukn.cn /cms/
www.edukn.com /cms/
bbs.edukn.com /cms/discuz/
home.edukn.com /cms/uchome/

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact [email protected]
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!