WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a Wordpress URL that looks like this "www.domain.com/wordpress-page" but I want people to be able to retrieve this page even if they type it without the dash (i.e., www.domain.com/wordpresspage"). Is there a WP setting that will redirect the incorrect URL to the correct one?

share|improve this question
Could it be the contrary, each time the user enters wordpress-page redirect to wordpresspage? – Thiago Locks Feb 13 '13 at 22:14

I'm sure there is a more elegant way of achieving your desires, however this method does work. Just tested it.

 * Redirect pages from array.
 * @author Michael Ecklund
 * @access public
 * @return void
public function redirect_pages(){
    /* Page from => Page to */
    $redirect_pages = array(
        'wordpresspage' => '/wordpress-page'
    /* Check all required redirections. */
    foreach($redirect_pages as $page_from => $page_to){
        /* Check the current page. */
            /* Redirect to proper page. */
            wp_redirect(site_url($page_to, 'http'), 301);

In order to fire the redirection properly, you will need to add a page for "wordpresspage", so that it can properly detect the current page and redirect to domain.com/wordpress-page/.

Add the action in order to trigger the hook.

add_action('template_redirect', array($this, 'redirect_pages'));
share|improve this answer
Thanks so much. – James Feb 13 '13 at 22:33
@James Please accept my answer if you feel satisfactory with my response. – Michael Ecklund Feb 13 '13 at 22:48

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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