regex - How do I redirect all requests for .html files to directories with respective names? -
first question grace appreciated! have site use have tens of thousands of .html files index.html files inside directories. example, file1.html has become /file1/ (/file1/index.html). don't want spend inodes on individual files this, hoping it'd possible in htaccess file. suppose it'd have test existence of directory isn't possible right?
add .htaccess in web root / directory
rewriteengine on rewritecond %{document_root}/$1 -d # dir exists? rewriterule ^(.*)\.html$ /$1/ [r=301,l]
Comments
Post a Comment