如何用 index.php 替换我服务器上的每个目录
how to replace every directory on my server with index.php
我试图确保我服务器上的每个目录都将用户重定向到 index.php,而不是让用户查看我的目录,如下图所示
我尝试使用 .htaccess 来执行此操作,而不是必须在每个目录上创建 index.php 但它没有用,下面是 .htaccess 的样子:
ErrorDocument 404 "<H1>Page Not Found!</H1>"
# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php73” package as the default “PHP” programming language.
<IfModule mime_module>
AddHandler application/x-httpd-ea-php73 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
#Alternate default index page
DirectoryIndex index.php
谁能帮忙解决这个问题?
所以我可以通过在 .htaccess
的顶部添加 Options -Indexes
来解决这个问题,下面是我的更新代码:
Options -Indexes
ErrorDocument 404 https://websitelink.com/404.php
ErrorDocument 403 https://websitelink.com
# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php73” package as the default “PHP” programming language.
<IfModule mime_module>
AddHandler application/x-httpd-ea-php73 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
#Alternate default index page
DirectoryIndex index.php
我试图确保我服务器上的每个目录都将用户重定向到 index.php,而不是让用户查看我的目录,如下图所示
我尝试使用 .htaccess 来执行此操作,而不是必须在每个目录上创建 index.php 但它没有用,下面是 .htaccess 的样子:
ErrorDocument 404 "<H1>Page Not Found!</H1>"
# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php73” package as the default “PHP” programming language.
<IfModule mime_module>
AddHandler application/x-httpd-ea-php73 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
#Alternate default index page
DirectoryIndex index.php
谁能帮忙解决这个问题?
所以我可以通过在 .htaccess
的顶部添加 Options -Indexes
来解决这个问题,下面是我的更新代码:
Options -Indexes
ErrorDocument 404 https://websitelink.com/404.php
ErrorDocument 403 https://websitelink.com
# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php73” package as the default “PHP” programming language.
<IfModule mime_module>
AddHandler application/x-httpd-ea-php73 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
#Alternate default index page
DirectoryIndex index.php