• Resolved phobic

    (@phobic)


    Hi there

    I have a fairly standard WP permalink setup with this in my .htaccess file:

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

    However, I need to change the name of a page, and I’d like to setup a rewrite/redirect from the old page to the new. In other words, this URL:

    https://example.com/old-page/?story=978

    should forward/rewrite to this:

    https://example.com/new-page/?story=978

    Eventually the rewrite won’t be required, I just need to be sure that any links to the old page remain in place.

    Any suggestions greatly appreciated!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Using a redirect directive in your .htaccess file seems the easiest method if it’s only a single page, or a couple of them:

    Redirect 301 /old-page/?story=978 /new-page/?story=978
    Thread Starter phobic

    (@phobic)

    thanks for the reply – I figured I could redirect, but I’m having trouble because those are dynamic URLs – there are many stories generated by a plugin. On a clean site I could probably figure this out with trial and error, but I’m having trouble coming up with a rewrite/redirect regex that plays nice with the existing wordpress permalink structure.

    Are you looking to redirect *all* /old-page/ to /new-page/?

    If so, try this, it will keep the query string and force a 301 permanent redirect:

    RewriteRule ^old-page/(.*?) new-page/$1 [QSA,R=301]
    Thread Starter phobic

    (@phobic)

    That looks like it will do the trick – many thanks jgs!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Mod_rewrite or redirect?’ is closed to new replies.