记录一下刚用mod_rewrite做的分域名以及静态化链接 codeigniter
时间:2009-02-24
来源:互联网
1.看看你的apache2/bin/httpd -l
里面有没有 mod_rewrite.so
没有的话请重编译 --with-rewrite
2.httpd.conf增加 load module(语法自己查)
重启apache的时候如果出现什么 in build的时候,表示已经把该模块编译到apache了,不需要加载了,去掉刚才那行 httpd.conf
3.打开你的conf/extra/httpd-vhosts.conf
找到你的虚拟主机,这是我的配置文件
我需要把7个频道分出来,注意,主机头正则不能.+?匹配,这样会干掉你的img.domain.com,所以谨慎点好
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "/data0/wwwroot/www2.domain.com/"
ServerName www.domian.com
ServerAlias game.domain.com soft.domain.com video.domain.com theme.domain.com ebook.domain.com pic.domain.com audio.domain
i.com domain.com
ErrorLog "|/usr/local/sbin/cronolog /data1/logs/httpd/www2/error_log.%Y%m%d"
CustomLog "|/usr/local/sbin/cronolog /data1/logs/httpd/www2/access_log.%y%m%d" combined
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(game|soft|video|theme|pic|audio|ebook)\.domain\.com$
RewriteRule ^(.+) %{HTTP_HOST}$1 [C]
RewriteRule ^(game|soft|video|theme|pic|audio|ebook)\.domain\.com(\/*)$ /index.php/$1
RewriteRule ^(game|soft|video|theme|pic|audio|ebook)\.domain\.com\/(lists|detail)\/(.*?)\.html$ /index.php/$1/$2/$3
</VirtualHost>
以上配置,能帮我把 http://www.domain.com/index.php/game 伪装为 http://game.domain.com
http://game.domain.com/lists/2/40.html => http://www.domain.com/index.php/game/lists/2/40
注意apache2/bin/apachectl restart
里面有没有 mod_rewrite.so
没有的话请重编译 --with-rewrite
2.httpd.conf增加 load module(语法自己查)
重启apache的时候如果出现什么 in build的时候,表示已经把该模块编译到apache了,不需要加载了,去掉刚才那行 httpd.conf
3.打开你的conf/extra/httpd-vhosts.conf
找到你的虚拟主机,这是我的配置文件
我需要把7个频道分出来,注意,主机头正则不能.+?匹配,这样会干掉你的img.domain.com,所以谨慎点好
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "/data0/wwwroot/www2.domain.com/"
ServerName www.domian.com
ServerAlias game.domain.com soft.domain.com video.domain.com theme.domain.com ebook.domain.com pic.domain.com audio.domain
i.com domain.com
ErrorLog "|/usr/local/sbin/cronolog /data1/logs/httpd/www2/error_log.%Y%m%d"
CustomLog "|/usr/local/sbin/cronolog /data1/logs/httpd/www2/access_log.%y%m%d" combined
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(game|soft|video|theme|pic|audio|ebook)\.domain\.com$
RewriteRule ^(.+) %{HTTP_HOST}$1 [C]
RewriteRule ^(game|soft|video|theme|pic|audio|ebook)\.domain\.com(\/*)$ /index.php/$1
RewriteRule ^(game|soft|video|theme|pic|audio|ebook)\.domain\.com\/(lists|detail)\/(.*?)\.html$ /index.php/$1/$2/$3
</VirtualHost>
以上配置,能帮我把 http://www.domain.com/index.php/game 伪装为 http://game.domain.com
http://game.domain.com/lists/2/40.html => http://www.domain.com/index.php/game/lists/2/40
注意apache2/bin/apachectl restart
作者: anvycn 发布时间: 2009-02-24
关键是url 正则匹配。

作者: 逆雪寒 发布时间: 2009-02-24
我觉得那个你不如建个二级域名指向了。
如果要是应用到会员每人一个链接上,这样实验还算可以理解。我觉得这样apache的增加不少负载吧
如果要是应用到会员每人一个链接上,这样实验还算可以理解。我觉得这样apache的增加不少负载吧
作者: anyforever 发布时间: 2009-03-03
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28