window环境apache服务器在本地添加域名
1、在如下的文件中添加域名以及IP
C:\Windows\System32\drivers\etc\hosts
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
127.0.0.1 ? ? ? xxx.xxx.com
2、在Apache服務器配置如下
<VirtualHost *:80>
ServerName?xxx.xxx.com
DocumentRoot "D:xxx\xxx\xxx\xxx"
</VirtualHost>
3、URL地址重寫修改:在windows下的Apache配置文件
<VirtualHost *:80>
ServerName api.xstudy.cn
DocumentRoot "D:xxx\xxx\xxx\xxx"
RewriteEngine on=====》重寫開啟
RewriteRule ^/([0-9a-z\_]+)/([0-9a-z\_]+)/([a-z0-9\_]+).do$ /$1.php?call=$2.$3 [PT] ====》重寫規則
</VirtualHost>
4、重寫規則略解
實際需要輸入的地址: ?test.php?call=test.test
想要輸入的美化后的地址:test/test/test.do
^/([0-9a-z\_]+)/([0-9a-z\_]+)/([a-z0-9\_]+).do$ / ? ? ? $1.php?call=$2.$3 ? ?[PT]
對地址做匹配和替換
前面部分是地址欄輸入的URL,$1,$2,$3代替了你在實際輸入的時候輸入的內容。
后面的部分是實際需要輸入的URL,每一個括號匹配一個 $n。
在你輸入美化后的地址,進行正則匹配,替換成為實際需要輸入的地址,然后訪問。
轉載于:https://www.cnblogs.com/wsh-ning/p/7462185.html
總結
以上是生活随笔為你收集整理的window环境apache服务器在本地添加域名的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 前端jQuery插件库
- 下一篇: 一路慢行的JavaScript之旅(ad