我正在尝试将我的apache vhosts文件配置为具有localhost / something主机名和“别名”主机名。我目前正在使用google api,并且它们不接受自定义别名作为url,因此我无法使其与我的自定义url一起使用。有什么想法怎么办?我当前的配置不起作用:
<VirtualHost 127.0.0.1:80>
ServerName localhost/go
ServerAlias localhost/go
DocumentRoot "D:/username/Web/server.dev/go"
</VirtualHost>
<Directory "D:/username/Web/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Deny,Allow
Allow from all
Require all granted
</Directory>
<VirtualHost *:80>
ServerName api.server.dev
ServerAlias api.server.dev
DocumentRoot "D:/username/Web/server.dev/api"
</VirtualHost>
##... more custom urls with subdomains cut out because it's unnecessary
<VirtualHost *:80>
ServerName adstrck.server.dev
DocumentRoot "D:/username/Web/server.dev/adstrck"
</VirtualHost>
### ALL OTHERS ###
<VirtualHost *:80>
ServerName www.server.dev
ServerAlias server.dev *.server.dev
DocumentRoot D:/username/Web/server.dev
</VirtualHost>
当我尝试访问127.0.0.1/go或localhost / go时,出现内部服务器错误。
也许你想要的是这样的东西
<VirtualHost 127.0.0.1:80>
ServerName localhost
ServerAlias server.dev *.server.dev
DocumentRoot "D:/username/Web/server.dev"
</VirtualHost>
<Directory "D:/username/Web/server.dev">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Deny,Allow
Allow from all
Require all granted
</Directory>
然后使用诸如http:// localhost / go之类的URL来查看站点。
在这里没有帮助。我既要使用本地主机,又要使用serveralias之类的server.dev
好的,您的示例中有一个类型,我没有重新检查documentroot,它缺少逗号。这确实有效,谢谢。(尽管它仅作为127.0.0.1起作用,但仍然.. :))
抱歉打错了。我已经解决了。
我还添加了
ServerAlias
一行,该行应该可以http://server.dev/go
工作(假设server.dev
解析为127.0.0.1
)