php - 我可以将 index.php 放在子目录中,但不在 url 中显示子目录吗?

标签 php .htaccess

我有一个网站,比如说 http://mysite.com .我想将 index.php 放在子目录 public_html/mysubdir/index.php 中。我希望 public_html/mysubdir/index.php 在用户转到 http://mysite.com 时执行.我希望 url 继续阅读 http://mysite.com。这可能吗?

最佳答案

如果您的网络服务器是 Apache,您可以使用 URL rewriting with mod_rewrite .

另一种选择是在根目录中创建一个 index.php,并在子目录中包含 index.php。

关于php - 我可以将 index.php 放在子目录中,但不在 url 中显示子目录吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9267168/

相关文章:

php - 通过 url 保护对文件和文件夹的访问

.htaccess - 使用 .htaccess 密码保护目录及其所有子文件夹

php - PHP 文件意外结束?

php - 禁止在一个目录中执行 PHP

php - 应该使用什么 http 状态代码来告诉客户端 session 已超时?

file - 如何使用 .htaccess 限制对一个或多个文件的访问?

php - 检查用户是否从mysql在线?

javascript - 根据下拉选择显示/隐藏内容

.htaccess - 删除index.php并重定向到https子域

performance - 其他解决方案,而不是 NGINX 的 .htaccess