【发布时间】:2014-11-27 12:46:08
【问题描述】:
我有一个托管帐户,上面有一个网站。我们称之为:www.example.com
在 cPanel 中,我设置了一个插件域:www.example2.com,它指向 www.example.com 上的一个文件夹:
www.example.com/example2
如果有人直接访问 www.example.com/example2,我该如何抛出 404 错误?
我已经在我的 .htaccess 文件中尝试过:
Options -Indexes
RewriteEngine On
Options +FollowSymLinks
RewriteRule ^example2(.*) - [R=404,L,NC]
但它没有用。它仍然显示 example2 文件夹的 index.php。 www.example.com 和 www.example2.com 网站都有自己的 .htaccess 文件。如果我禁用 www.example2.com 上的 .htaccess 文件,则上述重定向有效。
【问题讨论】:
标签: apache .htaccess mod-rewrite redirect http-status-code-404