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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.