WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] [closed] htaccess with 301 redirect of index.php pages (6 posts)

  1. Electric Studio
    Member
    Posted 4 years ago #

    Hello, thank you for looking. I have just replaced an old CMS website with a brand new WordPress solution, but am having issues with 301 redirecting the old URL to the new, SEO friendly URL's created by WP. The old URL's where are structured like:

    /index.php?p=conference_programme

    So when I do a 301 for that, it seems to collide with the line:

    RewriteRule . /index.php [L]

    The last bit just seems to remove the index,php part and doesn't redirect it. The complete htaccess code is:

    # BEGIN WordPress
    
    <IfModule mod_rewrite.c>
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress
    
    Redirect 301 /index.php?p=director http://www.oxfordanimalethics.com/who-we-are/director/
    Redirect 301 /index.php?p=advisers http://www.oxfordanimalethics.com/who-we-are/advisers/
    Redirect 301 /index.php?p=news http://www.oxfordanimalethics.com/about-the-centre/latest-news/

    Any help with this would be very appreciated.

  2. iridiax
    Member
    Posted 4 years ago #

    It's the ?p= part that's messing it all up. Try a Google search for: .htaccess redirect parameters

  3. Electric Studio
    Member
    Posted 4 years ago #

    I'll give it a go, thank you, but if you should come across a solution, i'd appreciate it.

  4. Mark / t31os
    Moderator
    Posted 4 years ago #

    Try this...

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{QUERY_STRING} ^p=director$ [NC]
    RewriteRule ^/index.php$ http://www.oxfordanimalethics.com/who-we-are/director/? [R=301,L]
    RewriteCond %{QUERY_STRING} ^p=advisers$ [NC]
    RewriteRule ^/index.php$ http://www.oxfordanimalethics.com/who-we-are/advisers/? [R=301,L]
    RewriteCond %{QUERY_STRING} ^p=news$ [NC]
    RewriteRule ^/index.php$ http://www.oxfordanimalethics.com/about-the-centre/latest-news/? [R=301,L]
    </IfModule>
  5. Electric Studio
    Member
    Posted 4 years ago #

    Yes, thank you, this works. Found this solution on the htaccess forum

  6. kelphugger
    Member
    Posted 4 years ago #

    t31os_ you seem to know your stuff, please help!!

    I have a similar situation, but what if i need to redirect to both a new domain and folder. Also, notice the addition of the (www.)

    Do I have to write a separate line for every unique page?
    PS this is a wordpress site

    examples:

    INDEX:
    http://olddomain.com ----> http://www.newdomain.com/newfolder/

    PAGES:
    http://olddomain.com/?p=528 ----> http://www.newdomain.com/newfolder/?p=528

    http://olddomain.com/?p=482 ----> http://www.newdomain.com/newfolder/?p=482

Topic Closed

This topic has been closed to new replies.

About this Topic