繁体   English   中英

(Apache)访问子域时禁止403

[英](Apache) Forbidden 403 when accessing subdomain

我想在Windows / XAMPP的Apache 2.2服务器上设置子域“商店”,如果我输入“ shop.localhost”作为URL,但是它将重定向到“ index.html”,但是一旦我尝试通过域“ sv443”进行连接.net”,它将重定向到我的文档根目录(“ /index.html”而不是“ /shop/index.html”)。 连接到“ sv443.net/shop/”虽然可以正常工作,甚至可以重定向到“ index.html”。


我正在使用Cloudflare处理DNS内容并添加了这些记录(我切断了IP地址部分):

在此处输入图片说明




这是我的httpd-vhosts.conf:

NameVirtualHost localhost:80

<VirtualHost localhost:80>
   ServerName localhost
   ServerAdmin sven.fehler@web.de

   DocumentRoot "c:/users/sv443/desktop/mamp htdocs"

   <Directory "c:/users/sv443/desktop/mamp htdocs">
     Options Indexes MultiViews FollowSymLinks
     AllowOverride None

     Order allow,deny
     Allow from all
     Require all granted

   </Directory>
</VirtualHost>

<VirtualHost shop.localhost:80>
   ServerName shop.localhost
   ServerAdmin sven.fehler@web.de

   DocumentRoot "c:/users/sv443/desktop/mamp htdocs/shop"

   <Directory "c:/users/sv443/desktop/mamp htdocs/shop">
     Options Indexes MultiViews FollowSymLinks
     AllowOverride None

     Order allow,deny
     Allow from all

     Require all granted
   </Directory>
</VirtualHost>




这是我的hosts.dat:

(only comments)

2.205.169.73 sv443.net

# localhost name resolution is handled within DNS itself.
#   127.0.0.1       localhost
#   ::1             localhost


127.0.0.1   localhost   shop.localhost




另外,如果遇到403或404,我还将该.htaccess文件添加到shop目录中,以重定向到index.html-删除此文件不能解决我的问题:

ErrorDocument 403 /shop/index.html
ErrorDocument 404 /shop/index.html




如果有人尝试连接,我会在Apache error.log中得到以下错误消息:

AH01630: client denied by server configuration: C:/Users/Sv443/Desktop/MAMP htdocs/shop/.html




谢谢你的帮助!

如果可以通过显式指定“ /index.html”而不是“ /”来获取内容,则在加载mod_dir之后,应在配置中添加DirectoryIndex index.html 这将定义未指定时要查找的默认文件。

对于您的VirtualHost:

<VirtualHost *:80>
    ServerName localhost
    ServerAlias www.example.com
    ServerAlias example.com

    LogLevel debug
    CustomLog "logs/example_access_log" combined
    ErrorLog  "logs/example_error_log"

    [... REST OF CONFIGURATION ...]
</VirtualHost>

<VirtualHost *:80>
    ServerName shop.localhost
    ServerAlias shop.example.com

    LogLevel debug
    CustomLog "logs/shop_access_log" combined
    ErrorLog  "logs/shop_error_log"

    [... REST OF CONFIGURATION ...]
</VirtualHost>

Apache根据请求中的域来决定对请求使用哪个VirtualHost。 如果找不到匹配项,它将使用文件中的第一个(此处为localhost)。 因此,除非您在VirtualHost中通过ServerAlias ...为其指定,否则您并不指向“商店”子域。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM