Add htaccess redirect code to Custom Code

Home Forums BulletProof Security Free Add htaccess redirect code to Custom Code

Viewing 7 posts - 16 through 22 (of 22 total)
  • Author
    Posts
  • #30859
    AITpro Admin
    Keymaster

    This example Redirect code/rule is called stand-alone htaccess code because it can go anywhere in an htaccess file and it is not dependent on any other htaccess code/rules to do what it does.  For ease of management, simplicity and organization, redirect rules should be added to this BPS Custom Code text box: CUSTOM CODE BOTTOM HOTLINKING/FORBID COMMENT SPAMMERS/BLOCK BOTS/BLOCK IP/REDIRECT CODE.  So when using the htaccess File Editor you can add your Redirect htaccess code anywhere you like in the root htaccess file.  htaccess files are distributed server configuration files.  So this example rule below will affect everyone/anyone including you.  You are instructing your server to redirect URI “old” to “new”.  If you added other Rewrite conditions, such as: RewriteCond %{REMOTE_ADDR} !^(xxx\.xxx\.xxx\.|yyy\.|zzz\.) then the redirect would only occur for IP addresses that are not xxx.xxx.xxx. or yyy. or zzz. Yes, BPS has the capability to lock the root htaccess file on the htaccess File Editor tab page. So if another plugin like Yoast does not unlock the root htaccess file automatically to perform writing to the root htaccess file, then effectively Yoast would be “blocked” from writing to the root htaccess file. Just depends on whether or not Yoast automates locking/unlocking (CHMOD) of htaccess files if/when Yoast writes to your root htacces file.

    RedirectMatch 301 ^/old$ https://example.com/new/
    #30887
    C.A. Gross
    Participant

    Great, thanks so much for all of your help.  Nice plugin so far.

    #38042
    kimberly
    Participant

    A permanent 301 redirect in your .htaccess file lets search engines and others know that an old link has been replaced by a new one. It’s the recommended method for directing traffic from an existing page. … An old file has moved locations, or the information is now contained in a new file.

    see here top 10 Solar Power Banks in 2019

    #38134
    Cyndie Shaffstall
    Participant

    I have followed the instructions on this page https://forum.ait-pro.com/forums/topic/htaccess-redirect-code-where-do-i-add-redirect-htaccess-code/, but there is no page in my BPS titled BPS Security Modes.

    3. Go to the BPS Security Modes page and click the Root Folder BulletProof Mode Activate button
    I have very simple redirects, but there are about 1700 of them. Here is an example:

    Redirect 301 /2018/06/06/register-health-it-2015-testing/ /compliance/onc-health-it-certification/health-it-testing-registration/
    Redirect 301 /2018/06/08/register-health-it-2014-testing/ /compliance/onc-health-it-certification/health-it-testing-registration/
    Redirect 301 /2018/06/06/register-health-it-2015-testing/ /compliance/onc-health-it-certification/health-it-testing-registration/

    When I follow steps 1 and 2 and add just a few redirects, it works. When I add all the rest, the site goes down with a 501 error. What am I doing wrong?

    #38135
    AITpro Admin
    Keymaster

    I assume the error was a 500 error and not a 501 error.  Most likely you have some htaccess code that is invalid, which is causing the 500 error.  The Security Modes page is under the B-Core main page for BPS Pro and under the htaccess Core main page for BPS free.  I think there is a better way to do your redirects using the RediretMatch htaccess directive with RegEx htaccess code instead of the plain Redirect htaccess directive, which does not allowing using RegEx htaccess code.  See the example code below.

    500 Internal Server Error
    A generic error message, given when an unexpected condition was encountered and no more specific message is suitable.

    501 Not Implemented
    The server either does not recognize the request method, or it lacks the ability to fulfill the request. Usually this implies future availability (e.g., a new feature of a web-service API).

    Instead of using 2 different redirect rules…

    Redirect 301 /2018/06/06/register-health-it-2015-testing/ /compliance/onc-health-it-certification/health-it-testing-registration/
    Redirect 301 /2018/06/08/register-health-it-2014-testing/ /compliance/onc-health-it-certification/health-it-testing-registration/

    You can use just this 1 redirect rule to do the redirects…

    RedirectMatch 301 ^/2018/06/06/register-health-it-(.*)-testing/$ https://www.example.com/compliance/onc-health-it-certification/health-it-testing-registration/
    #38136
    Cyndie Shaffstall
    Participant

    Thank you.

    #42262
    mamoxe
    Participant

    You must include the entire/full URL to redirect to when using Htaccess Redirect. Additionally, $1 is a backreference, which you wouldn’t want to utilize in this situation. Additionally, make sure to add the final slash at the end of the URL path to avoid receiving Soft

Viewing 7 posts - 16 through 22 (of 22 total)
  • You must be logged in to reply to this topic.