怎样为网站做二级域名泛解析(apache)原创
怎样为网站做二级域名霏虍锚揣泛解析,之前在网站百度,得到的都是没用的结果,而且转载泛滥...花了半天完成了这任务,特此分享下原创(详细步骤):
一.
得到解析了二级域名的网址,然后找到C盘里的hosts文件
(可能有些机子会提示无法修改,那么你得设置hosts文件权限)
在文件末尾加上下列代码:
# localhost name resolution is handled within DNS itself.
127.0.0.1 localhost
192.168.0.144 sell.****.com
二.找到apache配置,打开httpd.conf文件,如图
加上下列代码(主要是这句RewriteRule ^(.*)/list/([0-9]+)/([0-9]+)?([/])?$ $1/list.php?catid=$2&page=$3 配置,正则表达式要根据自身网站写的,这句只能做参考,否则用我的没用.):
Order allow,deny
Allow from All
LogLevel alert rewrite:trace8
RewriteEngine On
RewriteRule ^(.*)\.(asp|aspx|asa|asax|dll|jsp|cgi|fcgi|pl)(.*)$ /404.php
RewriteRule ^(.*)/file/(.*)\.php(.*)$ /404.php
RewriteRule ^(.*)/list/([0-9]+)/([0-9]+)?([/])?$ $1/list.php?catid=$2&page=$3
三.
在httpd.conf文件末尾加上下列代码:
NameVirtualHost 192.168.0.144:80
DocumentRoot "D:\wamp\www\abc\sell"
ServerName sell.****.com
(提醒: 192.168.0.144是本机IP地址,可以在cmd运行ipconfig查看,这样设置完成后在浏览器打开192.168.0.144就可以访问sell.****.com. 80是本机网站环境端口)
现在可以打开你设置的网址,就可以访问了.