服务器 Gind.cn

服务器问题集锦,包括 Linux(Ubuntu, Centos,Debian等)和Windows Server服务器

从一个域访问文件夹时返回404页,但允许从其他域和IP地址访问

情况: 当从example.com域访问一个文件夹(“hidden”)时,我想返回一个404页面(“404.php”)。 我希望可以从一个子域(“hidden.example.com”)或从一个不同的域(“hidden.com”)访问同一个文件夹,这两个域都在单个VirtualHost条目中configuration。 服务器有多个监听的IP地址。 每个IP地址提供与example.com域相同的内容(共享一个VirtualHost条目)。我希望可以从IP地址访问该文件夹。 服务器configuration为使用SSL / TLS / HTTPS。 HTTPS在example.com上是可选的,但HTTPS在隐藏文件夹的.htaccess文件中执行,使用下面显示的重写规则。 /www/hidden/.htaccess RewriteCond %{HTTPS} !=on RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R,L] 我知道{SERVER_ADDR}给出服务器的IP地址,但它是否返回客户端请求的IP地址? 我也开始认为在VirtualHosts文件中的东西会更合适。 对此有何想法? 应该允许什么: http://87.65.43.21/hidden/ https://87.65.43.21/hidden/ http://12.34.56.78/hidden/ https://12.34.56.78/hidden/ http://hidden.example.com/ https://hidden.example.com/ http://hidden.com/ https://hidden.com/ http://www.hidden.com/ https://www.hidden.com/ 404.php应该是404-ed http://example.com/hidden/ https://example.com/hidden/ http://www.example.com/hidden/ https://www.example.com/hidden/ http://example.com/hidden/hiddenfile.php https://example.com/hidden/hiddenfile.php etc. 谢谢。