I'm not sure this is possible, but I'd like to write a rewrite rule (and any other instruction if needed) in a .htaccess file so that, for every url in that folder, any url ending in .txt is rewritten to the same name ending in .php, but in addition, in this case the php file is NOT executed but its content (source code) is served instead.
That is, being "myfolder" the folder where I want this to apply:
http://www.mydomain.com/myfolder/somescript.php => would run somescript.php as usual http://www.mydomain.com/myfolder/somescript.txt => would return the source code of somescript.php without running it