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

dhxwm5r4  于 2023-11-21  发布在  Apache
关注(0)|答案(1)|浏览(245)

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

错误

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

配置

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

  1. Alias "/rtsis-fe" "C:/xampp/httpdocs/rtis-fe/dist/rtsis-fe"
  2. <Directory "C:/xampp/httpdocs/rtis-fe/dist/rtsis-fe">
  3. Options Indexes FollowSymLinks
  4. AllowOverride All
  5. Require all granted
  6. </Directory>
  7. ErrorLog "logs/rtsis-error.log"
  8. CustomLog "logs/rtsis-access.log" common
  9. RewriteEngine On
  10. # Rewrite all requests to index.html to enable Angular routing
  11. RewriteCond %{REQUEST_FILENAME} !-f
  12. RewriteCond %{REQUEST_FILENAME} !-d
  13. 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,添加以下代码:

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

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

  1. 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

展开查看全部

相关问题