Thursday, 15 September 2011

regex - How do I redirect all requests for .html files to directories with respective names? -


Firstly the question is so much appreciated! I have a site that uses thousands of .html files, which are now index.html files inside directories, for example, file1.html has become / file1 / < / Code> ( /file1/index.html ). I do not want to spend inodes on individual files to do this, so I expected that it would be possible to do this in a htaccess file, I think it will have to test the existence of that directory which is not really possible?

Add it to your .htaccess in your web root / directory

  RewriteCond% {DOCUMENT_ROOT} / $ 1-d # Dir exists on RewriteEngine? RewriteRule ^ (. *) Html $ / $ 1 / [R = 301, L]  

No comments:

Post a Comment