我们开发项目的时候经常会开发到浏览器版本的网页,这样我们就经常需要用手机连接局域网以方便测试,那么怎么配置服务器文件呢。
1.首先关闭电脑的windows防火墙 右击我的网络/windows防火墙/windows防火墙状态->点击关闭
2.wampsever服务器有两种状态(服务器在线状态和服务器离线状态);点击wampsever服务器切换到服务器在线状态。
3.配置HOST文件: 我的计算机/C磁盘/windows/system32/drivers/etc/HOSTS/
配置访问路径:
127.0.0.1 localhost
127.0.0.1 app.weilan.com
127.0.0.1 vip.weilan.com
127.0.0.1 wap.weilan.com
#0.0.0.1 mssplus.mcafee.com
127.0.0.1 betterway.com
127.0.0.1 yangzailu.com
127.0.0.1 2016.com
127.0.0.1 web.weilan.com
4.配置apache:
apache/apache2.4.9/conf/extra/httpd-vhosts.conf
配置:想用手机访问哪一个文件就把那个文件放到首位,默认加载第一个文件。
<VirtualHost *:80> ServerAdmin webmaster@dummy-host2.example.com ServerAdmin webmaster@dummy-host.example.com DocumentRoot "e:/www/WapSources/01 code" ServerName wap.weilan.com #ServerAlias www.dummy-host.example.com #ErrorLog "logs/dummy-host.example.com-error.log" #CustomLog "logs/dummy-host.example.com-access.log" common <Directory "e:/www/WapSources/01 code"> Options Indexes FollowSymLinks AllowOverride all Order allow,deny Allow from all </Directory> <IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK) RewriteRule .* - [F] Rewriterule ^(.*)/(.*)/index.html$ $1/index.php?$2 Rewriterule ^(.*)/(.*)/index(\d+).html$ $1/index.php?$2&page=$3 Rewriterule ^(.*)/(.*)/a(\d+)\.html$ $1/index.php?$2/$3 Rewriterule ^(.*)/u/(\d+)/(.*)$ $1/index.php?u&$2&$3 Rewriterule ^(.*)/u/(\d+)/(.*)/$ $1/index.php?u&$2&$3 Rewriterule ^(.*)/u/(\d+)$ $1/index.php?u&$2 Rewriterule ^(.*)/u/(\d+)/$ $1/index.php?u&$2 Rewriterule ^(.*)/(.*)/index.html\?(.*) $1/index.php?$2&$3 Rewriterule ^(.*)/(.*)/index(\d+).html\?(.*) $1/index.php?$2&$3 Rewriterule ^(.*)/index.action(.*) $1/index.php$3 </IfModule> </VirtualHost>
5.一定要确保自己的手机无线网和电脑的无线网络在一个局域网内部。