.htaccess (again!) - rewrite /page/ to page.php, but disallow page.php

Soldato
Joined
12 Dec 2006
Posts
3,421
Location
Worthing, West Sussex
Okay that was a poor effort at summarising in the title, what I mean is;

Code:
RewriteRule ^page/$ page.php [L]

So that makes requests for "site.com/page/" actually return "site.com/page.php".

If someone types in "site.com/page.php", they can still get to the page.

So I pretty much wanted to do this - so that requests for page.php get a 404 error whilst requests for /page/ get page.php;

Code:
RewriteRule ^page/$ page.php [L]
RewriteRule ^page.php$ non-existant-file-to-cause-404-error [L]

But as pretty much expected, that also makes "site.com/page/" give a 404. I only want a 404 if they type "site.com/page.php", so that page.php is only accessible if they visit "site.com/page/".

Is it possible to do what I'm talking about?

Cheers :)
 
Back
Top Bottom