如何解决Apache 2.4.37 在 docroot 之外的目录中通过别名访问文件时出现错误 404
请帮助我,我已经在这上面花费了足够多的时间,但没有取得很好的效果..
我的 /etc/httpd/conf.d/20-myweb-443.conf
中有以下配置:
<VirtualHost *:443>
ServerName myserver.com
## Vhost docroot
DocumentRoot /var/lib/sm
## Script alias directives
ScriptAlias /sm/sm.cgi "/usr/share/sm/cgi/sm.fcgi"
ScriptAlias /cgi-bin/ "/"
## Alias declarations for resources outside the DocumentRoot
Alias /sm/files /var/lib/sm/files
Alias /otherdata /var/lib/otherdata/files
<Directory /var/lib/sm/files>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Require all granted
AuthType None
</Directory>
<Directory /var/lib/otherdata/files>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Require all granted
AuthType None
</Directory>
## Logging
ErrorLog /var/log/httpd/error_ssl.log
LogLevel warn
ServerSignature Off
CustomLog /var/log/httpd/access_ssl.log combined
## SSL directives
SSLEngine on
SSLCertificateFile /etc/httpd/conf/ssl.crt/server.crt
SSLCertificateKeyFile /etc/httpd/conf/ssl.key/server.key
SSLCACertificatePath /etc/pki/tls/certs/
SSLCACertificateFile /etc/httpd/conf/ssl.crt/ca.crt
SSLOptions
<FilesMatch "\.(cgi|shtml|phtml|php|txt)$">
SSLOptions +StdEnvVars
</FilesMatch>
我可以正常访问 https://myserver.com/sm/sm.cgi
并且脚本正常显示所有内容。
当我尝试访问 https://myserver.com/otherdata
时,它向我显示了“/otherdata 索引”中列出的 2 个 (txt) 文件(尽管我注意到图标已“损坏”)。
但是,当我尝试通过单击链接访问这两个文件 (test.txt) 中的任何一个时,它给了我一个 404 The requested URL was not found on this server.
我得到的 url 是 https://myserver.com/test.txt
。尽管该文件显然在服务器 (/var/lib/otherdata/files/test.txt)
,它无法“找到”它。
别名有效,因为它确实将我重定向到文件夹位置 /var/lib/otherdata/files
并且对 test.txt
的权限是 755,所以是什么??
apachectl -S 输出如下:
apachectl -S
VirtualHost configuration:
*:443 myserver.com (/etc/httpd/conf.d/20-myweb-443.conf:1)
*:80 myserver.com (/etc/httpd/conf.d/20-myweb-80.conf:1)
ServerRoot: "/etc/httpd"
Main DocumentRoot: "/etc/httpd/htdocs"
Main ErrorLog: "/var/log/httpd/error_log"
Mutex ssl-cache: using_defaults
Mutex default: dir="/etc/httpd/run/" mechanism=default
Mutex fcgid-pipe: using_defaults
Mutex ssl-stapling-refresh: using_defaults
Mutex fcgid-proctbl: using_defaults
Mutex ssl-stapling: using_defaults
PidFile: "/etc/httpd/run/httpd.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="apache" id=48
Group: name="apache" id=48
感谢是否有人可以解释为什么无法访问文件? 当我尝试打开文件时收到 404 错误时,日志中没有实际错误..
谢谢 J
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。