我在我的计算机上运行了MAMP,虚拟主机project.dev已配置并正常工作(多年来一直在处理该项目)。现在我将project.dev添加到Android手机上的hosts文件中,指向我的本地IP。
我在移动Chrome中访问http://project.dev并且它到达我的MAMP就好了,但它加载了/ htdocs中的任何内容(基本上就像我在计算机的浏览器上访问了“localhost”),而不是加载虚拟主机。这就是我在httpd.conf文件中定义虚拟主机的方式:
NameVirtualHost project.dev
<VirtualHost project.dev:80>
ServerName project.dev
ServerAlias *.project.dev
DocumentRoot "/project/public/root"
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !^(.+)\.(js|css|png|jpg|swf|ico|txt|html|mp3)$
RewriteRule ^/(.+) /index.php [QSA,L]
AddDefaultCharset utf-8
</VirtualHost>
为什么不执行该规则并加载正确的文件并默认为MAMP的htdocs目录?
答案 0 :(得分:1)
<VirtualHost :80> # Specify IP here, not hostname. You can leave it at :80 too (Listen on any)
ServerName project.dev # For HTTP Host header
ServerAlias *.project.dev # Same thing. I'm not sure if wildcards work.
DocumentRoot /project/public/root
yada yada yada
</VirtualHost>