.htaccess 将子文件夹index.php重定向到子文件夹根目录
我有以下url,我想使用Mod Rewrite根目录中的.htaccess文件重定向。我在根目录中搜索并找到了索引文件的好例子,但在子文件夹中没有。 这就是我所拥有和需要的。 提前感谢您的帮助 /folder1/index.php /folder1/index.php/ 到 /folder2/index.php /folder2/index.php/ 到.htaccess 将子文件夹index.php重定向到子文件夹根目录,.htaccess,mod-rewrite,redirect,subdomain,subdirectory,.htaccess,Mod Rewrite,Redirect,Subdomain,Subdirectory,我有以下url,我想使用Mod Rewrite根目录中的.htaccess文件重定向。我在根目录中搜索并找到了索引文件的好例子,但在子文件夹中没有。 这就是我所拥有和需要的。 提前感谢您的帮助 /folder1/index.php /folder1/index.php/ 到 /folder2/index.php /folder2/index.php/ 到 我被要求只有2个超链接,所以我删除了上面例子中的部分链接。我很欣赏这种简短的方式,因为我有很多文件夹。请在您的.htaccess文件中尝试
我被要求只有2个超链接,所以我删除了上面例子中的部分链接。我很欣赏这种简短的方式,因为我有很多文件夹。请在您的.htaccess文件中尝试这种方式
RewriteEngine On
Rewrite ^/folder1/index.php$ /folder1/ [L]
<Directory folder1>
DirectoryIndex index.php
</Directory>
重新编写引擎打开
重写^/folder1/index.php$/folder1/[L]
DirectoryIndex.php
当然,索引可以是您想要的,比如newindex.php。要将/folder/index.php重定向到/folder,您可以使用:
RewriteEngine on
RewriteRule ^([^/]+)/index\.php$ /$1/ [NC,L,R]
这将重定向:
- /anyfolder/index.php
- /任意文件夹/