strange problem with Node Template

Yesterday I mentioned that the strange problem with my Drupal module "Node Template": If I enable the "clean URLs" in Drupal, then clicking on the menu item "my node templates" will show the message "access denied" with the error 403.

After long long time with try-error, finally I found the cause of the problem. In the .htaccess which is in the root folder of Drupal, there are some lines looked like this:

# Protect files and directories from prying eyes.
<FilesMatch "(\.(engine|inc|install|module|sh|.*sql|theme|tpl(\.php)?|xtmpl)|code-style\.pl|Entries.*|
Order deny,allow
Deny from all

Since I used "/nodetemplate" as the path for the menu item "my node templates", then the server will block this path only because the path "/nodetemplate" ends with the string "template". That's really a dreadful setting! I cannot suggest all the users to change their .htaccess file, so I changed my path to "/nodetemplates". BOOM! Everything works like a charm now.

Indeed, such kind of FilesMatch settings are intended to protect the unauthorized access to those files. But, it has so many side-effects. For example, you cannot use any string which ends with "template" or "root", etc. to name your shortcuts as your path in Drupal. If you did this, you will get the strange problem too!

No comments: