Change page URL structure based on node field value I'm using Pathauto to produce nice URLs for my Drupal 7 site, and have run into the need to edit the URLs based on a node field value. 

Specifically, when the content is archived on my website, the URL needs to be automatically changed to include the substring 'archive'. So when editing this page:

www.mysite.com/mypage


and node:field-status is changed from none to archived, I need the URL to become:

www.mysite.com/archive/mypage


Also, pages that already feature a substring, such as mysite.com/blog/mypage would ideally have the new substring prepended to the relative URL, so:

www.mysite.com/archive/blog/mypage


I have tried using Flags and Rules to rewrite the URL pattern based on the field value, but with no luck. Any ideas?
You can build a small module, called myalias and use this code to generate custom alias

&lt;?php
function myalias_node_insert($node){
    //here you can access the $node variable and get its fields value  
    $node-&gt;path['alias'] = 'your_custom_path';
}


You can also change the hook to myalias_node_update($node) to alter the node alias once it is updated.