[resolved] 301 redirect old site URLs (6 posts)

  1. joffff
    Posted 5 years ago #

    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?

  2. Did you put that ABOVE the WP calls in htaccess?

  3. joffff
    Posted 5 years ago #

    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:

    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]
    # END WordPress

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

  4. joffff
    Posted 5 years ago #

    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).

  5. 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.

  6. joffff
    Posted 5 years ago #

    Thanks (again), that's much simpler! :D

Topic Closed

This topic has been closed to new replies.

About this Topic