Title: Adjust Permalink Structure For Attachments
Last modified: August 19, 2016

---

# Adjust Permalink Structure For Attachments

 *  [bluntrizzle](https://wordpress.org/support/users/bluntrizzle/)
 * (@bluntrizzle)
 * [16 years, 8 months ago](https://wordpress.org/support/topic/adjust-permalink-structure-for-attachments/)
 * Hi there. I want to be able to rewrite (if possible) the base name for an attachement
   page for a post.
 * Here is an example:-
 * [http://www.domain.com/photos/36/summer-vactation/](http://www.domain.com/photos/36/summer-vactation/)**
   attachment**/beach-03/
 * [http://www.domain.com/photos/36/summer-vactation/](http://www.domain.com/photos/36/summer-vactation/)**
   gallery**/beach-03/
 * I want to change the attachment part to another word, rather than having the 
   default way with “attachment”
 * I’ve tried looking through the rewrite.php file but it does not make sense.
 * I have managed to change the link structure in the link-template.php file to:-
 * >  if ( is_numeric($object->post_name) || false !== strpos(get_option(‘permalink_structure’),‘%
   > category%’) )
   >  $name = ‘**gallery**/’ . $object->post_name; // <permalink>/
   > <int>/ is paged so we use the explicit attachment marker
 * This doesn’t work when the link is launched, it just 404s. Do I need to edit 
   the htaccess file for it to over ride this?
 * I am not much of a programmer, so your help would be appreciated.
 * Thanks in advance.

Viewing 1 replies (of 1 total)

 *  Thread Starter [bluntrizzle](https://wordpress.org/support/users/bluntrizzle/)
 * (@bluntrizzle)
 * [16 years, 8 months ago](https://wordpress.org/support/topic/adjust-permalink-structure-for-attachments/#post-1222338)
 * I’ve searched through the codex and found this example to add in an extra line
   for htaccess:-
 * > RewriteRule ^post/([0-9]+)?/?([0-9]+)?/?$ /index.php?p=$1&page=$2 [QSA]
 * [http://codex.wordpress.org/Using_Permalinks#Long_Permalinks](http://codex.wordpress.org/Using_Permalinks#Long_Permalinks)
 * Could I possibly do something more similar where I would have it structured like
   this:-
 * > domain.com/%category%/%post_id%/%postname%/gallery/%image_name%/
 * There doesn’t seem to be a setting for this in the WordPress admin so I’m guessing
   this will have to be either an easy hack replacing a certain line of code in 
   the wp-includes folder or just adding another line in the htaccess.
 * Hope you guys can help, thanks.

Viewing 1 replies (of 1 total)

The topic ‘Adjust Permalink Structure For Attachments’ is closed to new replies.

## Tags

 * [attachment](https://wordpress.org/support/topic-tag/attachment/)
 * [permalink](https://wordpress.org/support/topic-tag/permalink/)

 * 1 reply
 * 1 participant
 * Last reply from: [bluntrizzle](https://wordpress.org/support/users/bluntrizzle/)
 * Last activity: [16 years, 8 months ago](https://wordpress.org/support/topic/adjust-permalink-structure-for-attachments/#post-1222338)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
