Title: rewrite
Last modified: August 19, 2016

---

# rewrite

 *  Resolved [sevennine](https://wordpress.org/support/users/sevennine/)
 * (@sevennine)
 * [17 years, 8 months ago](https://wordpress.org/support/topic/rewrite-1/)
 * Hey everyone, I have a short rewrite situation. I’m trying to rewrite all calls
   to a page. Let me illustrate. I’d like all calls that are children of my files
   page `URL/files/filename` to get changed into `URL/files/?file=filename`.
 * What I’m trying to do is clean up the URLs so that I don’t have links linking
   back to my theme directory in my page source, it would just link to the files
   page and then with a little PHP magic it’ll fetch the file from the theme directory
   for me.
 * Here’s what I have but it doesn’t seem to be working. Thoughts?
 *     ```
       function file_rewrite_rules($wp_rewrite) {
   
       	$new_rules = array('files/(.+)/?$' => 'index.php?pagename=files&file=$matches[1]');
   
       	$wp_rewrite->rules = $new_rules + $wp_rewrite->rules;
       }
   
       // Hook in.
       add_filter('generate_rewrite_rules', 'file_rewrite_rules');
       ```
   

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [sevennine](https://wordpress.org/support/users/sevennine/)
 * (@sevennine)
 * [17 years, 8 months ago](https://wordpress.org/support/topic/rewrite-1/#post-824445)
 * just found a wicked tutorial to help out… well it’s actually a plugin but you
   can figure it out from looking at the code
    [http://www.whypad.com/posts/wordpress-plugin-url-rewrite/194/](http://www.whypad.com/posts/wordpress-plugin-url-rewrite/194/)
 *  [wordpress4you](https://wordpress.org/support/users/wordpress4you/)
 * (@wordpress4you)
 * [17 years, 4 months ago](https://wordpress.org/support/topic/rewrite-1/#post-824681)
 * So where was your bug?

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘rewrite’ is closed to new replies.

## Tags

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

 * 2 replies
 * 2 participants
 * Last reply from: [wordpress4you](https://wordpress.org/support/users/wordpress4you/)
 * Last activity: [17 years, 4 months ago](https://wordpress.org/support/topic/rewrite-1/#post-824681)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
