WordPress.org

Ready to get started?Download WordPress

Forums

BulletProof Security
[resolved] Where to add 301 Redirects? (52 posts)

  1. gotmedia
    Member
    Posted 1 year ago #

    Hi there,

    I'm trying to figure out where I can add several redirects? I'm just trying to redirect an old page to the new page.

    I tried doing it at a few places, but it's not working. Not sure if it's a plugin problem or a host problem. Thoughts?

    http://wordpress.org/extend/plugins/bulletproof-security/

  2. AITpro
    Member
    Plugin Author

    Posted 1 year ago #

    This is an online htaccess redirect code generator >>> http://www.htaccessredirect.net/

    It is going to depend on what you are trying to redirect and to where.
    Please post specific examples of what you are trying to do. Also are the redirects inside the WordPress rewrite loop or outside the WordPress rewrite loop?
    Example:

    //301 Redirect Old File
    Redirect 301 somefile.php somefile-new-location.php

    //301 Redirect Entire Directory
    RedirectMatch 301 /some-folder/(.*) /some-new-folder-location/$1

  3. AITpro
    Member
    Plugin Author

    Posted 1 year ago #

    Did this info answer your question? If so, please resolve this question. Thanks.

  4. AITpro
    Member
    Plugin Author

    Posted 1 year ago #

    Ok well i guess you are crazy busy so i am resolving this thread. please reopen it if you need any other info. Thanks.

  5. gotmedia
    Member
    Posted 1 year ago #

    Hi!

    Well, the redirects are sort of outside the loop. This is a redirect I'd like to happen:

    http://www.wepcoinc.com/smartroller.html
    should redirect to
    http://www.wepcoinc.com/smartroller/ (now WordPress)

    I see the link you gave me. What would you like me to do with the code that it generates? Where would that go?

    Thank you!

  6. AITpro
    Member
    Plugin Author

    Posted 1 year ago #

    Ok then you would do something like this then if you are in the scenario of generally trying to redirect ALL old html pages from a site that was previously an HTML site to a new site that is now WordPress.

    http://stackoverflow.com/questions/11926237/redirecting-old-html-page-to-new-without-html-extension-page

    You would add your redirect code to BPS Custom Code, save this code, then click the AutoMagic buttons and activate BulletProof Mode for your Root folder again.
    Root htaccess File Custom Code

    CUSTOM CODE TOP: Add php.ini handler code and / or miscellaneous custom code here

    ...
    ...Add your new redirect custom code here...
    ...

  7. gotmedia
    Member
    Posted 1 year ago #

    Hi there,

    Thanks! However, some pages are going to be different.

    There will probably be a few like this:

    http://www.wepcoinc.com/home_r1.html
    redirects to
    http://www.wepcocinc.com/conveyors/

    So do I follow the same instructions (as in adding the code to the BPS custom code, etc.)?

    Thank you!

  8. AITpro
    Member
    Plugin Author

    Posted 1 year ago #

    how many pages total do you have to redirect? it might be better to just do the redirects individually if you only have a small number of them - 100 pages or less to redirect.

  9. AITpro
    Member
    Plugin Author

    Posted 1 year ago #

    so if you want the simplest and most basic redirect method for a small number of redirects then here it is:

    This redirects a file named example-page.html that is in the website root folder to a blog post named conveyors. Your redirect for home_r1.html to blog post conveyors is also shown.

    RedirectMatch 301 /example-page.html /conveyors/index.php
    
    or without displaying index.php
    
    RedirectMatch 301 /example-page.html /conveyors/
    
    RedirectMatch 301 /home_r1.html /conveyors/index.php
    
    or without displaying index.php
    
    RedirectMatch 301 /home_r1.html /conveyors/
  10. AITpro
    Member
    Plugin Author

    Posted 1 year ago #

    I assume this answered all of your questions. Resolving this thread. Thanks.

  11. MIGPRO
    Member
    Posted 11 months ago #

    Thank you for the information!

    I have followed your instructions with regard to using the custom code and for the first time (from the various methods I have tried), the redirect is working. However, the redirect is going to the main page, rather than the desired page.

    This is all on the same domain... I am cleaning up old .php and .html pages that have been replaced with WordPress pages.

    Is there another setting that is forcing redirects to the main page?

    This is the redirect I tested with:
    Redirect 301 /immunocal.science.php http://www.immunocal.md/science/

    When I go to the old URL, I arrive at immunocal.md

    What is my next step?

    Thanks!

  12. AITpro
    Member
    Plugin Author

    Posted 11 months ago #

    Use RedirectMatch instead of redirect and in your case it is important to escape the dot otherwise the dot will match more than just a single/literal dot and match anything. I am not sure why you were adding the domain name. You are just trying to match and redirect the file named science.php correct?

    RedirectMatch 301 ^/science\.php$ http://www.immunocal.md/science/

  13. AITpro
    Member
    Plugin Author

    Posted 11 months ago #

    comment/code was updated...

  14. MIGPRO
    Member
    Posted 11 months ago #

    No, the original page is http://immunocal.md/immunocal.science.php

    In fact, the very first page was with .html extension, so I have to redirect that one also. I have a whole list of pages to redirect.

  15. AITpro
    Member
    Plugin Author

    Posted 11 months ago #

    Well that might be a problem since your file name is the same as your domain name and could cause a redirect loop, but it may not - very strange file name??? Try it...

    RedirectMatch 301 ^/immunocal\.science\.php$ http://www.immunocal.md/science/

  16. MIGPRO
    Member
    Posted 11 months ago #

    Yes, I was (and still am) learning about SEO...

    I will try doing one of the files that does not contain immunocal in the name and will also try your suggestion... back shortly.

  17. AITpro
    Member
    Plugin Author

    Posted 11 months ago #

    Or this would work... OOPs i was leaving the "t" off of RedirectMatch. Fat fingered it. ;)

    RedirectMatch 301 ^/(.*)\.science\.php$ http://www.immunocal.md/science/

  18. MIGPRO
    Member
    Posted 11 months ago #

    Hmmmm... now I have a 500 internal server error and everything is off?

  19. AITpro
    Member
    Plugin Author

    Posted 11 months ago #

    yep typo. Add the "t" to RedirectMatch. I corrected my previous posts and added the "t".

  20. MIGPRO
    Member
    Posted 11 months ago #

    I can't do anything... Can't even Restore Backup? Everything is giving me a 500 error.

  21. AITpro
    Member
    Plugin Author

    Posted 11 months ago #

    download the .htaccess file in your website root folder and delete it from your website, log back in and create a new htaccess file by activating Root BulletProof Mode again.

  22. AITpro
    Member
    Plugin Author

    Posted 11 months ago #

    If you need to add any .htaccess code from your old .htaccess file then copy and paste it from the .htaccess file you downloaded. Do not copy and paste the typo back into your new htaccess file...

  23. MIGPRO
    Member
    Posted 11 months ago #

    ok, site is back online... working on a couple things here.

    I tried a different redirect (without immunocal in the extension) and I am getting the same thing:

    Redirect 301 /glutathione.php http://www.immunocal.md/glutathione/
    Redirect 301 /glutathione.html http://www.immunocal.md/glutathione/

    I will test your other suggestion now.

  24. MIGPRO
    Member
    Posted 11 months ago #

    ok, this did not work either:

    RedirectMatch 301 ^/(.*)\.science\.php$ http://www.immunocal.md/science/

    Is it possible that there is a setting somewhere that is causing all redirects to go to the main URL?

  25. AITpro
    Member
    Plugin Author

    Posted 11 months ago #

    Use RedirectMatch NOT redirect. RedirectMatch allows you to use Regex and redirect does NOT.

    RedirectMatch 301 ^/glutathione\.php$ http://www.immunocal.md/glutathione/
    RedirectMatch 301 ^/glutathione\.html$ http://www.immunocal.md/glutathione/
  26. AITpro
    Member
    Plugin Author

    Posted 11 months ago #

    Yep something is fubar. Judging by the file naming convention that was used I can only imagine what else is fubar. LOL

  27. AITpro
    Member
    Plugin Author

    Posted 11 months ago #

    LOL your have redirects on redirects or in other words you are looping. When i go to the /science URL it sends me back to the Home page. You have a loop/mistake somewhere.

  28. MIGPRO
    Member
    Posted 11 months ago #

    Yes, this is what I am trying to figure out...

  29. AITpro
    Member
    Plugin Author

    Posted 11 months ago #

    Can't help you there. You need to download your .htaccess files as backups and start all over again. Or track down where the redirect from the /science folder is that is redirecting to your home page. it could be in your .htaccess file for that site or it could be in your control panel. This is where i get off the bus. ;)

  30. MIGPRO
    Member
    Posted 11 months ago #

    Thanks very much for your help, we are getting somewhere now... I think the old redirect is from the old host. There must be something there on their server still because I moved this entire site to a new host, but left a couple others.

    Thanks again!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic