PHP - 阻止来自其他域的请求

发布于 2024-09-18 09:28:33 字数 488 浏览 0 评论 0原文

我有一些像这样的链接

http://www.domain1.com/files/domain1.com/files/def.jpg

http://super.domain1.com/files/super.domain1.com/files/abc.jpg

http://www.other1.com/files/other1.com/files/uhj.jpg

这些网站托管在同一托管和共享文件文件夹中。我们使用一个名为网站域名的子文件夹将它们分开。但是,属于domain1.com: 的文件

http://www.domain1.com/files/domain1.com/files/def.jpg

可以通过url 访问

http://www.other1.com/files/domain1.com/files/def.jpg

如何防止这种情况?

I have some links like this

http://www.domain1.com/files/domain1.com/files/def.jpg

http://super.domain1.com/files/super.domain1.com/files/abc.jpg

http://www.other1.com/files/other1.com/files/uhj.jpg

These websites are hosted in the same hosting and sharing files folder. We separate them by using a sub folder named like domain name of website. However, file which belong to domain1.com:

http://www.domain1.com/files/domain1.com/files/def.jpg

can be reach with url

http://www.other1.com/files/domain1.com/files/def.jpg

How to prevent this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你没皮卡萌 2024-09-25 09:28:33

分别为每个域配置虚拟主机到域文件夹。

我在下面发布的虚拟主机配置示例。

<VirtualHost *:80>

        ServerAdmin webmaster@localhost
        ServerName www.domain1.com

        DocumentRoot /home/domains/files/super.domain1.com/

        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>

        <Directory /home/domains/files/super.domain1.com/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>

        ErrorLog /var/log/apache2/error.log
        LogLevel warn
        CustomLog /var/log/apache2/access.log combined

</VirtualHost>

<VirtualHost *:80>

        ServerAdmin webmaster@localhost
        ServerName domain1.com

        DocumentRoot /home/domains/files/super.domain1.com/

        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>

        <Directory /home/domains/files/super.domain1.com/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>

        ErrorLog /var/log/apache2/error.log
        LogLevel warn
        CustomLog /var/log/apache2/access.log combined

</VirtualHost>

Get configure for each domain separately vhost to domain folder.

Example of vhost config i post below.

<VirtualHost *:80>

        ServerAdmin webmaster@localhost
        ServerName www.domain1.com

        DocumentRoot /home/domains/files/super.domain1.com/

        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>

        <Directory /home/domains/files/super.domain1.com/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>

        ErrorLog /var/log/apache2/error.log
        LogLevel warn
        CustomLog /var/log/apache2/access.log combined

</VirtualHost>

<VirtualHost *:80>

        ServerAdmin webmaster@localhost
        ServerName domain1.com

        DocumentRoot /home/domains/files/super.domain1.com/

        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>

        <Directory /home/domains/files/super.domain1.com/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>

        ErrorLog /var/log/apache2/error.log
        LogLevel warn
        CustomLog /var/log/apache2/access.log combined

</VirtualHost>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文