将嵌套文件夹(子子文件夹)重定向到自己的index.php

时间:2018-11-27 21:31:05

标签: php apache .htaccess cpanel

如何从example.com/projects/login重定向到example.com/projects/login/index.php

我的.htaccess:

#Force www:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301,NC]

#Removing .PHP Extension
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

# Set XSS Protection header
<IfModule mod_headers.c>
Header set X-XSS-Protection "1; mode=block"
</IfModule>

1 个答案:

答案 0 :(得分:2)

这不需要任何重写规则。只需在.htaccess顶部使用trainable=False指令:

DirectoryIndex