我想知道是否可以有一个像 www.example.com
这样的域和一个像 www.example.com/test_dir
这样的目录并且在 test_dir
有一个名为 test.html
的文件和另一个名为 test2.html
的文件以及 .htaccess
或其他文件方法是将 www.example.com/test_dir
重定向到 www.example.com/test_dir/test.html
?
谢谢
最佳答案
你可以在根.htaccess
中使用:
RewriteEngine On
RewriteRule ^test_dir/?$ test_dir/test.html [NC,L]
如果你想改变 URL。使用:[NC,R=301,L]
关于html - 将目录重定向到目录中的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34010066/