PHP头条
热点:

记录一下刚用mod_rewrite做的分域名以及静态化链接 codeigniter





记录一下刚用mod_rewrite做的分域名以及静态化链接 codeigniter
解决方法
1.看看你的apache2/bin/httpd l
里面有没有 mod_rewrite.so
没有的话请重编译 withrewrite
2.httpd.conf增加 load module(语法自己查)
重启apache的时候如果出现什么 in build的时候,表示已经把该模块编译到apache了,不需要加载了,去掉刚才那行 httpd.conf
3.打开你的conf/extra/httpdvhosts.conf
找到你的虚拟主机,这是我的配置文件
我需要把7个频道分出来,注意,主机头正则不能.+?匹配,这样会干掉你的img.domain.com,所以谨慎点好

ServerAdmin [url=http://www.phpchina.com/bbs/mailto:www@domain.com]链接标记www@domain.com[/url]
DocumentRoot "/data0/wwwroot/www2.domain.com/"
ServerName [url=http://www.domian.com/]链接标记www.domian.com[/url]
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


以上配置,能帮我把 [url=http://www.domain.com/index.php/game]链接标记http://www.domain.com/index.php/game[/url] 伪装为 [url=http://game.domain.com/]链接标记http://game.domain.com[/url]
[url=http://game.domain.com/lists/2/40.html]链接标记http://game.domain.com/lists/2/40.html[/url] => [url=http://www.domain.com/index.php/game/lists/2/40]链接标记http://www.domain.com/index.php/game/lists/2/40[/url]
注意apache2/bin/apachectl restart

[ ]


D8888D回贴内容
关键是url 正则匹配。[img]http://www.phpchina.com/bbs/images/smilies/default/biggrin.gif[/img]
D8888D回贴内容
我觉得那个你不如建个二级域名指向了。
如果要是应用到会员每人一个链接上,这样实验还算可以理解。我觉得这样apache的增加不少负载吧

www.phpzy.comtrue/php/29783.htmlTechArticle记录一下刚用mod_rewrite做的分域名以及静态化链接 codeigniter 记录一下刚用mod_rewrite做的分域名以及静态化链接 codeigniter 解决方法 1.看看你的apache2/bin/httpd l 里面有没有 mod_rewrite.so 没有的...

相关文章

    暂无相关文章

PHP之友评论

今天推荐