By Todd Young on
I would like to have an entire site publicly available - no user accounts, no logging in - where every page is viewable by anonymous users but ONLY if they know the direct path specified for any given node. I would like to BLOCK users from accessing nodes by the default "/node/xxx" URL's.
I imagine I could add something to the page template to tank the request if the URL contains "node" in it, and/or do some .htaccess tricks, but I thought there might be a more elegant way?
Comments
This is what you
This is what you need.
http://drupal.org/project/globalredirect
Thanks for the pointer,
Thanks for the pointer, trying it now.
From the Global Redirect notes:
I'm hoping this can actually be configured to not allow the node/123 version of the URL. I am trying to prevent people from "crawling" the site by incrementing the node number. Off to try it...
Shoot, as I suspected...
Shoot, as I suspected... Global Redirect does not stop a user from typing "node/2" and still getting that page, even though it redirects to the assigned path. I think I'm back to the drawing board?
I'd like to block requests using the node/# but allow requests to the assigned path. Global Redirect was close - any ideas?
If there are no user
If there are no user accounts, how are you making changes? As user 1?
Rather than put something in template.php, I'd perhaps make a small module and handle it something like this (untested):
Yes, only user 1.
Yes, only user 1. Interesting approach, thanks for the code... I'm wondering if the cron check is needed and/or if it would provide a user the ability to see the node while cron is running. I will tinker...
I think cron can run as
I think cron can run as anonymous - I found the check necessary to avoid cron-run errors when doing something very similar in hook_nodeapi.
Partial Response to an old question
Someone emailed me asking if I had a solution for this problem. If I can remember correctly, I believe I ended up creating a penel for that node type and put a php conditional statement in there to read the URL and test if "/node/" was in it, sending the user to 404 if it was. I think. It was some time ago.
At any rate, that should work.