Title: Adding custom URLs
Last modified: August 19, 2016

---

# Adding custom URLs

 *  [ArkaneArkade](https://wordpress.org/support/users/arkanearkade/)
 * (@arkanearkade)
 * [16 years ago](https://wordpress.org/support/topic/adding-custom-urls/)
 * Hey all,
 * I’m in dire need of some sanity here. I’ve been playing about with this for hours,
   and don’t understand the slightest of my issue.
    I’m trying to add custom links
   into my plugin, so that my site doesn’t look so nasty. I have the pages currently
   working using $_GET (sortof… if I refresh a page that seems to break, and sometimes
   randomly fails). I’ve done the usual search all over the web, and found several
   sites which cover it, but copying them doesn’t seem to work for me. Here’s my
   code:
 *     ```
       register_activation_hook(__FILE__,'do_flush_gear'); 
   
       function do_flush_gear()
       {
           global $wp_rewrite;
           $wp_rewrite->flush_rules();
       } 
   
       function add_my_loc_var($public_query_vars) {
           $public_query_vars[] = 'locale';
           return $public_query_vars;
       }
   
       add_filter('query_vars', 'add_my_loc_var');
   
       function do_rewrite_urls() {
           add_rewrite_rule('accommo/(.+)/?$', 'index.php?pagename=locations&location=$matches[1]','top');
       }
   
       add_action('init', 'do_rewrite_urls');
       ```
   
 * Currently my site uses this for the pages: “[http://www.c2c-guide.co.uk/locations/?location=Whitehaven&#8221](http://www.c2c-guide.co.uk/locations/?location=Whitehaven&#8221);
   
   and I’d like to change that to be “[http://www.c2c-guide.co.uk/accommo/Whitehaven&#8221](http://www.c2c-guide.co.uk/accommo/Whitehaven&#8221);
   but for whatever reason the code listed above doesn’t work, and instead that 
   takes me to “[http://www.c2c-guide.co.uk/locations/directions/whitehaven-directions/&#8221](http://www.c2c-guide.co.uk/locations/directions/whitehaven-directions/&#8221);
 * Can anyone help me solve this problem, and shed some light on the issue?

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

 *  [Josh Leuze](https://wordpress.org/support/users/jleuze/)
 * (@jleuze)
 * [16 years ago](https://wordpress.org/support/topic/adding-custom-urls/#post-1504045)
 * Any particular reason you aren’t using [Pretty Permalinks](http://codex.wordpress.org/Using_Permalinks#Using_.22Pretty.22_permalinks)?
 *  Thread Starter [ArkaneArkade](https://wordpress.org/support/users/arkanearkade/)
 * (@arkanearkade)
 * [16 years ago](https://wordpress.org/support/topic/adding-custom-urls/#post-1504068)
 * It does have pretty permalinks enabled, but the plugin itself needs the location
   $_GET. My hope is to get this working to remove that question mark once and for
   all, since it’s only the plugin which uses it.

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

The topic ‘Adding custom URLs’ is closed to new replies.

 * 2 replies
 * 2 participants
 * Last reply from: [ArkaneArkade](https://wordpress.org/support/users/arkanearkade/)
 * Last activity: [16 years ago](https://wordpress.org/support/topic/adding-custom-urls/#post-1504068)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
