WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Using htaccess to 301 redirect, not working (11 posts)

  1. Patrick
    Member
    Posted 3 years ago #

    Hi there, Im using htaccess to redirect some old blog posts, following some advice I got in another forum string.
    
    However, every time I try to add the new htaccess I get an internal error, could someone tell me what I've done wrong here?
    
    Thanks in advance.
    
        # 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
    
    redirect 301 /real-mortgage-for-real-people http://www.mortgageadvicecenter.co.uk/mortgage-news
    redirect 301 /are-you-not-the-perfect-mortgage-applicant http://www.mortgageadvicecenter.co.uk/mortgage-news
    redirect 301 /there-are-funds-available-to-borrowers http://www.mortgageadvicecenter.co.uk/mortgage-news
  2. Patrick
    Member
    Posted 3 years ago #

    Apologies for placing all of that in code! The explaination says:
    Hi there, Im using htaccess to redirect some old blog posts, following some advice I got in another forum string.

    However, every time I try to add the new htaccess I get an internal error, could someone tell me what I've done wrong here?

    Thanks in advance.

  3. Patrick
    Member
    Posted 3 years ago #

    Anyone know why this isn't working?

  4. wptorgue
    Member
    Posted 3 years ago #

    yes indeed I do :)

    First of all - the wordpress rules are redirecting every URL (that are not real files or directories) to index.php. So - this means that the .htaccess file will never execute your last rules of redirects.

    However; in your case that wouldn't do much of a difference; you see - htaccess files are a bit more tricky than common logic dictates: You might very well experience, if you move your "Redirect 301" lines above the mod_rewrite rules, that they will still have no effect - mod_rewrite always gets executed BEFORE any redirect statements.

    So; you will have to convert them to "RewriteRule" statements instead I am agraid.

    (so in conclussion: 1) move the three lines ABOVE the #being wordpress. If this works - hurray. 2) convert the lines to rewrite lines instead.

  5. Patrick
    Member
    Posted 3 years ago #

    Hi there,

    Thanks so much for taking the time to respond. Option 1 didn't work - still got the internal error 500.

    How would I go ahead with option 2?

    Thanks again.

  6. Patrick
    Member
    Posted 3 years ago #

    Also, is this the only option?

    Thanks

  7. Patrick
    Member
    Posted 3 years ago #

    @wptorgue - any more ideas? Thanks!

  8. dynamicden
    Member
    Posted 3 years ago #

    I had the very same question. After a lot of digging I was able to figure it out. Try something like this...

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^real-mortgage-for-real-people$ http://www.mortgageadvicecenter.co.uk/mortgage-news/ [R=301,L]
    RewriteRule ^are-you-not-the-perfect-mortgage-applicant$ http://www.mortgageadvicecenter.co.uk/mortgage-news/ [R=301,L]
    RewriteRule ^there-are-funds-available-to-borrowers$ http://www.mortgageadvicecenter.co.uk/mortgage-news/ [R=301,L]
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    # END WordPress
  9. Patrick
    Member
    Posted 3 years ago #

    Thanks very much for taking the time to respond :-)

  10. travxrose
    Member
    Posted 2 years ago #

    Hi,

    I know this is kind of an old thread but I tried this solution for my site and I had no luck. I am getting an Internal Error 500. I think this has to do with the fact that my WordPress site is @ /home rather than in the index.

    Any suggestions to making this work for me?

  11. PinkishHue
    Member
    Posted 2 years ago #

    Hi everyone,

    I had this same problem and tried a few different methods including those above and nothing worked.

    I installed this plugin: http://wordpress.org/extend/plugins/simple-301-redirects/

    and that seems to have done the job, although certain URL's that contained brackets - ( or ) - are still not redirecting so I think that may be what was causing the problem.

    I also noticed as I was adding the URLs in to the plugin that I had a couple of errors in the list of 301's that was causing the 500 internal error, but even with these removed the other redirects didn't work (they just went to the new WP homepage instead of the new URL)

    I recently added 301 redirects to a WP htaccess file that didn't contain any of these funky characters in the URLs and everything worked fine, so I'm fairly sure they are likely to be the culprit.

    Hope this is of some help to other people experiencing this annoying issue.

Topic Closed

This topic has been closed to new replies.

About this Topic