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 - as long as the files are on a part of your server outside of the Mambo document root). 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:
Options +FollowSymLinks //not needed on some servers
RewriteEngine On
# Blocking direct access
RewriteCond %{HTTP_REFERER} !^http://(www\.)?example\.com/ [NC] //change example.com to your domain
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.
If you enjoyed this post, make sure you subscribe to my RSS feed!













