langqiao 2013-01-09
我的域名,服务器空间全是万网的,操作系统windows 2003,服务器是Apache 服务器
共分2个步骤。
1.实现二级域名,入blog.xxx.com进入博客,www.xxx.com进入商城,book.xxx.com进入书城。
2.ecshop实现URL重写,伪静态。
*******************************************************************************
一:实现二级域名
*******************************************************************************
1。如上图所示,二级域名就可以成功了。可能还包括xxx.com进入网站主题,那么就新增一个域名解析,主机记录(RR)值为空就可以了。
2.修改本机的hosts文件,如下: C:\WINDOWS\system32\drivers\etc\hosts。如下图操作即可。
*******************************************************************************
二:apache 实现ecshop实现URL重写,伪静态。
*******************************************************************************
1。在 httpd.conf 中搜索 LoadModule rewrite_module,将该行前面的 # 号删除。下图选中的文字便是。LoadModule rewrite_module启用apache的伪静态写入(ecshop如果想启用伪静态必须开启此项)。
其次: httpd.conf文件,分别去掉下面两行文字前面的#号。
#LoadModulevhost_alias_modulemodules/mod_vhost_alias.so
去掉#意思是启用apache的虚拟主机功能。
#Includeconf/extra/httpd-vhosts.conf (如果想启用二级域名入blog.xxx.com进入博客,必须启动此项。)
去掉这一行的#意思是从conf/extra/httpd-vhosts.conf这个文件导入虚拟主机配置。2.将下列代码出入到httpd.conf底部即可。
<VirtualHost *:80> ServerAdmin [email protected] DocumentRoot "D:/hltdpath/project/ecshop" ServerName www.xxxxxx.com <IfModule mod_rewrite.c> RewriteEngine On RewriteRule ^(.*)/index.html$ $1/index.php RewriteRule ^(.*)/category$ $1/index.php [L] RewriteRule ^(.*)/feed-c([0-9]+).xml$ $1/feed.php?cat=$2 [L] RewriteRule ^(.*)/feed-b([0-9]+).xml$ $1/feed.php?brand=$2 [L] RewriteRule ^(.*)/feed-type([^-]+)\.xml$ $1/feed\.php\?type=$2 [L] RewriteRule ^(.*)/feed.xml$ $1/feed.php [L] RewriteRule ^(.*)/category-([0-9]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([^-]*)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$ $1/category.php?id=$2&brand=$3&price_min=$4&price_max=$5&filter_attr=$6&page=$7&sort=$8&order=$9 [QSA,L] RewriteRule ^(.*)/category-([0-9]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([^-]*)(.*)\.html$ $1/category.php?id=$2&brand=$3&price_min=$4&price_max=$5&filter_attr=$6 [QSA,L] RewriteRule ^(.*)/category-([0-9]+)-b([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$ $1/category.php?id=$2&brand=$3&page=$4&sort=$5&order=$6 [QSA,L] RewriteRule ^(.*)/category-([0-9]+)-b([0-9]+)-([0-9]+)(.*)\.html$ $1/category.php?id=$2&brand=$3&page=$4 [QSA,L] RewriteRule ^(.*)/category-([0-9]+)-b([0-9]+)(.*)\.html$ $1/category.php?id=$2&brand=$3 [QSA,L] RewriteRule ^(.*)/category-([0-9]+)(.*)\.html$ $1/category.php?id=$2 [QSA,L] RewriteRule ^(.*)/goods-([0-9]+)(.*)\.html$ $1/goods.php?id=$2 [QSA,L] RewriteRule ^(.*)/article_cat-([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$ $1/article_cat.php?id=$2&page=$3&sort=$4&order=$5 [QSA,L] RewriteRule ^(.*)/article_cat-([0-9]+)-([0-9]+)-(.+)(.*)\.html$ $1/article_cat\.php\?id=$1&page=$2&keywords=$3 [QSA,L] RewriteRule ^(.*)/article_cat-([0-9]+)-([0-9]+)(.*)\.html$ $1/article_cat.php?id=$2&page=$3 [QSA,L] RewriteRule ^(.*)/article_cat-([0-9]+)(.*)\.html$ $1/article_cat.php?id=$2 [QSA,L] RewriteRule ^(.*)/article-([0-9]+)(.*)\.html$ $1/article.php?id=$2 [QSA,L] RewriteRule ^(.*)/brand-([0-9]+)-c([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)\.html $1/brand.php?id=$2&cat=$3&page=$4&sort=$5&order=$6 [QSA,L] RewriteRule ^(.*)/brand-([0-9]+)-c([0-9]+)-([0-9]+)(.*)\.html $1/brand.php?id=$2&cat=$3&page=$4 [QSA,L] RewriteRule ^(.*)/brand-([0-9]+)-c([0-9]+)(.*)\.html $1/brand.php?id=$2&cat=$3 [QSA,L] RewriteRule ^(.*)/brand-([0-9]+)(.*)\.html $1/brand.php?id=$2 [QSA,L] RewriteRule ^(.*)/tag-(.*)\.html $1/search.php?keywords=$2 [QSA,L] RewriteRule ^(.*)/snatch-([0-9]+)\.html$ $1/snatch.php?id=$2 [QSA,L] RewriteRule ^(.*)/group_buy-([0-9]+)\.html$ $1/group_buy.php?act=view&id=$2 [QSA,L] RewriteRule ^(.*)/auction-([0-9]+)\.html$ $1/auction.php?act=view&id=$2 [QSA,L] RewriteRule ^(.*)/exchange-id([0-9]+)(.*)\.html$ $1/exchange\.php\?id=$2&act=view [QSA,L] RewriteRule ^(.*)/exchange-([0-9]+)-min([0-9]+)-max([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$ $1/exchange\.php\?cat_id=$2&integral_min=$3&integral_max=$4&page=$5&sort=$6&order=$7 [QSA,L] RewriteRule ^(.*)/exchange-([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$ $1/exchange\.php\?cat_id=$2&page=$3&sort=$4&order=$5 [QSA,L] RewriteRule ^(.*)/exchange-([0-9]+)-([0-9]+)(.*)\.html$ $1/exchange\.php\?cat_id=$2&page=$3 [QSA,L] RewriteRule ^(.*)/exchange-([0-9]+)(.*)\.html$ $1/exchange\.php\?cat_id=$2 [QSA,L] </IfModule> </VirtualHost>
3、ServerName www.xxxxxx.com,红色部分替换成你自己的域名, DocumentRoot "D:/hltdpath/project/ecshop",红色替换成你的项目地址,保存 httpd.conf。
4、将 ecshop 目录下的 htaccess.txt 重命名为 .htaccess。
5、重新启动 Apache。
6、进入 ecshop 管理中心->商店设置,将 URL 重写设置为启用。
最后大功告成了啊!
以上内容同时参考了http://blog.sina.com.cn/s/blog_74c4720501014b0s.html内容,作为感谢了吧!