我們開發項目的時候經常會開發到浏覽器版本的網頁,這樣我們就經常需要用手機連接局域網以方便測試,那麼怎麼配置服務器文件呢。
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 [email protected] ServerAdmin [email protected] 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.一定要確保自己的手機無線網和電腦的無線網絡在一個局域網內部。