1

I have a content type with a field allowing to select public or private.

I am using the Pathauto module for generating path aliases using this field, using /[node:field_evt_diffusion]/[node:title] as pattern. I am using the CAS module to casify the /private/* path.

Is it possible to create two path aliases for the same node?

  • 1
    If I understand this right, no. When the path is made, if you edit this node and change that field value or node title, the path will be updated and a 301 will be created. If you create a new node with the same title and same field value as another, you will get /field-value/node-title-0, /field-value/node-title-1 etc etc – Kevin Mar 8 '18 at 14:57
  • so is there a way to get around that ? having 2 adresses need necessary duplicating content? – Matoeil Mar 8 '18 at 15:09
  • Pathauto will only give you the first best match. Manually you can rebatch the pattern. Automatically on save, you would probably be better off passing it through a .htaccess RewriteRule. Even if you hook into Redirect, apparently it doesn't like patterns and tokens. – piet Mar 8 '18 at 23:05
1

If manual steps are OK you can use this workaround:

The pathauto module always generates aliases using the first matching pattern type/condition combo. So simply create two matching patterns for your nodes. Generate URLs using the first pattern, deactivate this pattern and rerun URL alias generation (which now automatically uses the 2nd matching pattern).

  • thanks. i am looking for smthg automatic on node save anytime an editor is editing a content – Matoeil Mar 8 '18 at 14:46
1

You could use the redirect module to accomplish this with How to create a redirection programmatically?

Alternatively, if you change the url alias, redirect will automatically create a new redirect.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.