By AcidReflux on
I have created a new content type for which I am using pathauto to created aliased urls for. I would like to prevent access to the node via the /node/ url for just this content type. Users would have use the alias url instead to access the node.
I have attempted to search for any past work in this area but I have not found anything. Does anyone know if this is possible?
Comments
Many contributed modules
There are many contributed modules that provide similar functionality. The best choice depends on the specifics of what you're trying to do. See http://drupal.org/project/content_access and other related modules in the http://drupal.org/project/Modules/category/74 list.
Not quite what I'm looking for
I'm not sure these give me what I want. I took a look through the entire list and any access control talks about access to the node in general. In my situation I would have two urls to access a node:
1. /node/1
2. /my/custom/url
For a specific node type I want to prevent access via #1 and only allow access via #2.
None of the modules in that category appear to operate on that level, but instead focus on node access control. In this case it would deny both #1 and #2.
The global redirect module provides functionality almost the way I want. If a user accesses #1 they are redirected to #2. For this node type I don't want that to happen (all other node types this behavior is fine). Instead reporting 404 or 403 would be nice.
use this module
use this module http://drupal.org/project/globalredirect
--
Cheers,
Sivanandhan, P. (a.k.a. apsivam)
See reply above
See my comment above. The global redirect module would redirect every /node/ url. In my case, for a specific content type I don't want this.
Then you need to hack Global
Then you need to hack Global Redirect module to cater your need. Not everything in life comes in boxed packing.
--
Cheers,
Sivanandhan, P. (a.k.a. apsivam)
Understood. I just don't
Understood. I just don't want to reinvent the wheel if someone has already done this :)
workflow_ng will do the job
Hi,
I was looking for the same thing, since I'm building my site with panels.
Here is a solution for your needs - Workflow-ng, though right now there is a small bug there. But it will be possible (the module is being fixed very quickly).
Note, that for anonymous users, for this to work, you will need to disable page cache.
---
gizra.com - where cool software developers meet geek fashion designers
Hmmm, interesting module.
Hmmm, interesting module. Although I'm not sure I like the restriction for anonymous users and the page cache. But I'll poke around.
So far as a non-developer
So far as a non-developer that is the only way I found.
---
gizra.com - where cool software developers meet geek fashion designers
I hacked up Global Redirect
I hacked up Global Redirect to do what I wanted. It's not a 100% clean hack, but it was relatively simple. Thanks for the pointer, that module might come in handy later.
Hi, Since I and probably
Hi,
Since I and probably other also need something similar, can you share the info with us? Maybe even better create a patch against GlobalRedirect module.
---
gizra.com - where cool software developers meet geek fashion designers
I don't think I can easily
I don't think I can easily create a patch, but here's the code I added (with some context before and after). You'll want to replace contenttype with the machine readable name of the content type you want to enable this for. This is where you can see what a hack it is. Ideally there would be a configuration page with a list of your content types to enable this for.
At a basic level the first if looks for urls of the node/ format and makes sure there is no query string (edit, delete, etc). I then look up the node id in the db and check it's type. I then redirect the user to the homepage with a 404. It would be better to send them to the official 404 page, but so far I haven't found the correct method to do this.
Hello, I made a module based
Hello,
I made a module based on your script.
I needed it in a project. I'm planning to improve it !
You can find it here: http://github.com/Polzme/AOA
Any improvements is, of course, welcome !
-Pol-
https://not-a-number.io/
A simple Regex Rewriterule will help you.
I had a similar issue. All the nodes on my websites are being created by anonymous users.
Still i want to keep those nodes private for those anonymous users.
There is a simple htaccess rule to make this possible in combination with "Extended path aliases".
Read more @ http://jobjol.nl/notes/preventing-access-nodenid-paths-htaccess
Very good idea too ! Thanks
Very good idea too ! Thanks for sharing !
-Pol-
https://not-a-number.io/