apache 尝试访问Windows服务器上的虚拟主机配置时遇到403禁止错误

dhxwm5r4  于 6个月前  发布在  Apache
关注(0)|答案(1)|浏览(76)

尝试访问Windows服务器上的虚拟主机配置时遇到403禁止错误
我正在为我的Angular应用程序配置一个虚拟主机,但我一直遇到403错误。提供的配置旨在将传入的请求定向到服务器,但它并没有按预期运行。

错误

AH 01630:客户端被服务器配置拒绝:C:/xampp/httpdocs

配置

` <VirtualHost *:80> DocumentRoot“C:/xampp/httpdocs”服务器名称192.168.0.32

Alias "/rtsis-fe" "C:/xampp/httpdocs/rtis-fe/dist/rtsis-fe"

<Directory "C:/xampp/httpdocs/rtis-fe/dist/rtsis-fe">
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

ErrorLog "logs/rtsis-error.log"
CustomLog "logs/rtsis-access.log" common

RewriteEngine On

# Rewrite all requests to index.html to enable Angular routing
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /rtsis-fe/index.html [L]

字符串
`

stszievb

stszievb1#

在Xampp中,默认的文档根目录(在httpd.conf中配置)是“htdocs”,而不是“httpdocs”。此外,Xampp使用的标准IP是127.0.0.1,而不是192.168.0.32。此外,您的vhost配置不必要地复杂。编辑原始的C:\xampp\apache\conf\extra\httpd-vhosts.conf,添加以下代码:

<VirtualHost *:80>
    DocumentRoot "C:\xampp\htdocs\rtis-fe\dist\rtsis-fe"
    ServerName rtsis
    ErrorLog "logs/rtsis-error.log"
    CustomLog "logs/rtsis-access.log" common
    # Rewrite all requests to index.html to enable Angular routing
    <If "%{REQUEST_URI} != '/index.html' ">
        RedirectMatch "/.*" "http://rtsis/index.html"
    </If>
</VirtualHost>

字符串
由于您正在为服务器(rtsis)使用localhost以外的其他名称,因此必须将此名称包含在文件C:\Windows\System32\drivers\etc\hosts中。向其中添加以下行:

127.0.0.1   rtsis


现在,输入http://rtsis访问您的网页。
注意事项:我假设你已经实现了文档根文件夹结构,并且在其中有一个index.html文件。在这个基本的测试之后,将任何文件或文件夹放在你的index.html文件旁边,并尝试请求它们(只有当你在httpd-vhosts.conf文件中注解了重定向代码并在之后重新启动Apache时才有可能)。
顺便说一下:你收到了一个403(禁止),可能是因为Xampp中的httpd.conf文件被配置为在htdocs文件夹中启用请求,而不是在“httpdocs”文件夹中!
参考文献:
https://httpd.apache.org/docs/2.4/rewrite/avoid.html

相关问题