|

Email to friend
* Your name:
* Your email:
* Friend's email:
Comment:


Blocking direct access to scripts in your wrapper

Sometimes we use the wrapper to bring into our Mambo site an external script. For example, on one of my sites I have a blog that is not integrated into Mambo, but by using the wrapper, the visitors to that site get to see it as if it is part of Mambo. The problem is, although the blog is wrapped, it is also sitting there on the internet under its own URL.

So, how did I stop people from going to blog.domain.com? This solution not only stops visitors from directly accessing the script, but also ensures that search engines don't list the stand-alone URL. All visitors, whether human or search engine MUST get to the blog through the wrapper link.

First, create an .htaccess file (if your script does not already have one) and place it in the root OF THE SCRIPT.
In my example, the .htaccess is in the root of the blog directory. (Note: this solution works whether your script resides in a directory or in a subdomain). Do NOT use the .htaccess in your Mambo installation - it must only be used in the directory containing the external script!.

Add this code, replacing the domain name with the domain name of the site you are adding this to:

RewriteEngine On 
RewriteBase /

# Blocking direct access
RewriteCond % !^http://www.domain.com/.*$ [NC]
RewriteCond % !^http://domain.com/.*$ [NC]
RewriteCond % ^.*index\\.php$ RewriteRule .* - [F]

That's it! Visitors can access your script with no problems, via the
wrapper link in your Mambo site, but cannot directly access the script.


RSS