This website is now static html (since the end of 2010). The pages you see here are a simple wget spider mode crawl of the original wordpress, thus dynamic features like commenting are not working anymore.

Drupal, hide install text files using rewrite rules


I see lots of web sites that are using drupal cms and most of them are not hiding the text files that the installation process leave in the root directory. This is not a problem in general, but if you use an old version of drupal maybe is better not to show them to the world. Take a look at drupal.org changelog file (yes this site is supposed to be up of date;).

So I use this basic solution, note that I update drupal using cvs method so I hide also the CVS directories. Put this code in your .htaccess file after RewriteEngine on inside the IfModule mod_rewrite.c section:

RewriteRule    ^(.*)CHANGELOG\.txt$  http://www.yoursite.net [R,L]
RewriteRule    ^(.*)INSTALL\.mysql\.txt$  http://www.yoursite.net [R,L]
RewriteRule    ^(.*)INSTALL\.txt$  http://www.yoursite.net [R,L]
RewriteRule    ^(.*)MAINTAINERS\.txt$  http://www.yoursite.net [R,L]
RewriteRule    ^(.*)CVS$  http://www.yoursite.net [R,L]
RewriteRule    ^(.*)CVS/$  http://www.yoursite.net [R,L]
RewriteRule    ^(.*)INSTALL\.pgsql\.txt$  http://www.yoursite.net [R,L]
RewriteRule    ^(.*)LICENSE\.txt$  http://www.yoursite.net [R,L]
RewriteRule    ^(.*)UPGRADE\.txt$  http://www.yoursite.net [R,L]

Modify to fix your needs and save the .htaccess file.

F.A.Q.

1 – Why you use tons of rules for every file and not something like ^(.*)\.txt$ ?

Mhh, I really don’t remember, maybe I have some text file I want to be accessible in the site.

2 – Why not just removing that text files?

I think that CVS imports them on every update, so you have to remove the files many times.



Leave a Reply