Simple question, let's pretend I have the following path:
http://example.com/subdir/index.html
I would like to be able to open that index.html page by typing this in the browser:
www.example.com/subdir
and hit enter to have the browser load its included index.html
page.
Is that possible?
My goal is to have a few subdirectories with the same root domain ( example.com ) and be able to open the index.html pages of each subdirectory without having to add /index.html
at the end.
Thanks so much!
For sub folders only put this in main root .htaccess
file :
RewriteEngine On
RewriteRule ^(.*)/index([\.html]*)$ /$1 [R=302,L]
For entire website change it to this :
RewriteEngine On
RewriteRule ^(.*)index([\.html]*)$ /$1 [R=302,L]
So , any request with index
or index.html
will be removed .
Note : clear your browser cache then test it , if Ok change 302
to 301
to get permanent redirection
如果您的服务器运行的是Apache,则只需创建.htaccess
文件(如果尚未创建),然后在文件顶部添加以下行:
DirectoryIndex index.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.