views:

32

answers:

0

Hi!

I want to write a .htaccess script that checks where a request is coming from and where it wants to end up. And depending on the result maybe do an action.

For example, I want all scripts that are run from "/websites/{identifier}/" to pass a validation. If said script is trying to reach for a file or directory that is not in "/websites/{same_identifier}/" it will automatically redirect the request.

Some visual examples (request => redirect):

"/websites/{identifier}/" => "/websites/{identifier}/"
"/websites/" => "/websites/{identifier}/"
"/websites/{identifier}/script.php" => "/websites/{identifier}/script.php"
"/websites/script.php" => "/websites/{identifier}/script.php"

Can it be done? How?

Cheers!