Forums

htaccess with 301 redirect of index.php pages (5 posts)

  1. Electric Studio
    Member
    Posted 1 month 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 1 month 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 1 month ago #

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

  4. t31os_
    Member
    Posted 1 month 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 1 month ago #

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

Reply

You must log in to post.

About this Topic