WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] 301 redirect old site URLs

[Resolved] 301 redirect old site URLs

  • An old site has been redesigned using WordPress and I’d like to redirect old pages to their equivalent in WordPress.

    The old site used a CMS which had pages in the format of index.php?page=2 which conflicts with WordPress’s own querystring structure. I’ve got around 20 URLs to redirect, all as index.php?page=x

    I’ve tried using mod_rewrite as such:

    RewriteCond %{QUERY_STRING} page=2
    RewriteRule ^index\.php$ http://www.domain.co.uk/new/wordpress/page/ [R=301,L]

    But of course WordPress treats it as it’s own URL and not a rewritten one. Any suggestions?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Did you put that ABOVE the WP calls in htaccess?

    No, I’d put it after!
    Thanks, it’s now at least acting on the rule first, but it’s now getting caught in a redirect loop.

    If it helps, the entire .htaccess contents are:

    SetEnv DEFAULT_PHP_VERSION 5
    
    DirectoryIndex index.cgi index.php
    
    RewriteCond %{QUERY_STRING} page=2
    RewriteRule ^index\.php$ http://www.domain.co.uk/newpage/ [R=301,L]
    
    # 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>
    
    # END WordPress

    Removing the L from the redirect rule just gives a 301 Moved Permanently message.

    I’ve come up with a solution, but not sure if it’s the correct one. Instead of redirecting to the permalink URL (which wasn’t working as above), I’ve redirected to the non-permalink URL (domain.com/?p=1).

    That works too. It you only have 20 pages, though, you may as well just do this:

    Redirect 301 /index.php?page=2 http://www.domain.co.uk/newpage/

    for all 20.

    Thanks (again), that’s much simpler! 😀

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Resolved] 301 redirect old site URLs’ is closed to new replies.