Post by kelvin_wang » Thu Feb 14, 2008 7:43 pm

hi, all,

i install a opencart site. and i find that .tpl file is accessable direct by url,(eg. http://www.myopencartshop.com/catalog/t ... layout.tpl), and the source code will display on the screen.

how to disallow user access .tpl files directly?

Newbie

Posts

Joined
Thu Feb 14, 2008 4:52 pm

Post by grimlock » Thu Mar 13, 2008 8:49 am

I can't access the demo pages like this, please try going to http://demo.opencart.com/template/default/layout.tpl it won't work.

This is not a bug.

Thanks

Newbie

Posts

Joined
Thu Mar 13, 2008 8:47 am

Post by bruce » Thu Mar 13, 2008 9:44 am

I can...

You will find that it is related to the setup of your web server.

One way of restricting this, which also gives a cleaner result than even the demo site is to put the following into your .htaccess file in the root directory of your web store (in my demo, it is the folder "store" in htdocs) It is an example of url rewriting so mod_rewrite needs to be enabled on your web server.

Code: Select all

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.+)\.tpl$ /store/index.php?controller=home [r=301,nc]
What it does is create a redirect to your home page for anyone who tries to access a file with extension .tpl on your web store by url.

Note that for the purpose of this demonstration, this is the only thing in the .htaccess file.

Active Member

Posts

Joined
Wed Dec 12, 2007 2:26 pm

Post by vot » Fri Mar 21, 2008 3:11 pm

kelvin_wang wrote: how to disallow user access .tpl files directly?
Just go to the catalog/template directory
and create .htaccess file with the next body:
deny from all

vot
Newbie

Posts

Joined
Sun Mar 09, 2008 3:11 am
Who is online

Users browsing this forum: No registered users and 4 guests