Hello,
I want to achieve the following effect:
If the user goes to "script.php" he gets a 404 not found error.
If the user goes to "page.htm" he gets the output of script.php.
In other words, I want to hide the fact that script.php exists at all, but still be able to direct its output to page.htm.
I am working on a per-directory basis with .htaccess.
This rule works fine by itself:
RewriteRule ^script.php$ nonexistent.htm
nonexistent.htm doesn't exist, and the user gets 404 if he types "script.php" in the browser.
This rule also works fine by itself:
RewriteRule ^page.htm$ script.php [T=application/x-httpd-php]
If the user goes to page.htm (which doesn't exist), he gets the output of script.php, but the location bar still says "page.htm".
However, if I combine the rules in the .htaccess file to cover both possibilities it doesn't work:
RewriteRule ^script.php$ nonexistent.htm [L]
RewriteRule ^page.htm$ script.php [T=application/x-httpd-php,L]
Notice I added the "L" flags, but now I get a 404 in both cases --> page.htm becomes script.php becomes nonexistent.htm and 404. (I verified this by setting nonexistent.htm to a real page, and it always went there if you went to either page.htm or script.php).
Originally I wanted script.php to become page.htm in the browser but keep the same output, but I ended up with an infinite loop, even with the "L" flags, which I don't understand...
Can anyone explain if what I want is possible or what I'm doing wrong? Why is the rule pointing to the nonexistent page always invoked? According to the docs, they are processed in order, and I'm not using re-directs. (I tried the rules in opposite order, same result.)
Andy Serpa
chessmad@chessopolis.com
http://www.chessopolis.com