Jump to content

.htaccess to stop direct access to .php files


mds1256

Recommended Posts

Hi

 

I currently have my site setup to rewrite .php to null so for example http://mydomain.com/registration  actually maps to http://mydomain.com/registration.php

 

But there is nothing to top anyone from typing in http://mydomain.com/registration.php. I want to stop them from doing that so it would come up 404.

 

In essence im trying to hide to the user what language the site is written in

Hmmm....  If that were the case, I would just make a custom extension so you could do like page.code or page.c or something.  That way if they did find it, no big deal.  Another option would be as you said, to just deny direct access to any file (and by "deny" I mean a 404 page).  You could probably accomplish that with a clever RewriteCond and a RewriteRule (with the Cond checking if the file exists).  Note that you'll need to order your rewrites correctly and mark the one rewriting /registration to /registration.php as final (with [F]).

 

I'm actually kind of curious on this now, so if I decide to mess with it I'll post whatever I use.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.