<p>I hope I can explain this clearly enough, but if not let me know and I'll try to clarify.</p>

<p>I'm currently developing a site using ColdFusion and have a mod_rewrite rule in place to make it look like the site is using PHP. Any requests for index.php get processed by index.cfm (the rule maps *.php to *.cfm).</p>

<p>This works great - so far, so good. The problem is that I want to return a 404 status code if index.cfm (or any ColdFusion page) is requested directly.</p>

<p>If I try to block access to *.cfm files using mod_rewrite it also returns a 404 for requests to *.php.</p>

<p>I figure I might have to change my Apache config rather than use .htaccess</p>

[{'answer_id': 8861, 'author': 'jj33', 'author_id': 430, 'author_profile': 'https://Stackoverflow.com/users/430', 'pm_score': 0, 'selected': False, 'text': "<p>Post the rules you already have as a starting point so people don't have to recreate it to help you.</p>\n\n<p>I would suggest testing [L] on the rule that maps .php to .cfm files as the first thing to try.</p>\n"}, {'answer_id': 8927, 'author': 'PW.', 'author_id': 927, 'author_profile': 'https://Stackoverflow.com/users/927', 'pm_score': 0, 'selected': False, 'text': '<p>You have to use two distinct groups of rewrite rules, one for .php, the other for .chm and make them mutually exclusives with RewriteCond %{REQUEST_FILENAME}. And make use of the flag [L] as suggested by jj33.</p>\n\n<p>You can keep your rules in .htaccess.</p>\n'}, {'answer_id': 12062, 'author': 'T Percival', 'author_id': 954, 'author_profile': 'https://Stackoverflow.com/users/954', 'pm_score': 2, 'selected': True, 'text': '<p>You can use the <code>S</code> flag to skip the <code>404</code> rule, like this:</p>\n\n<pre><code>RewriteEngine on\n\n# Do not separate these two rules so long as the first has S=1\nRewriteRule (.*)\\.php$ $1.cfm [S=1]\nRewriteRule \\.cfm$ - [R=404]\n</code></pre>\n\n<p>If you are also using the <code>Alias</code> option then you should also add the <code>PT</code> flag. See the <a href="http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html" rel="nofollow noreferrer">mod_rewrite documentation</a> for details.</p>\n'}]
['https://Stackoverflow.com/questions/8832', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1025/']