• Resolved rpost

    (@rpost)


    Hello. My .htaccess config is using redirecting rules (HTTP -> HTTPS). I think error logging (403.php) doesn’t work because of this redirecting rules.

    I have shortened the .htaccess file for the example:

    
    ErrorDocument 403 /wp-content/plugins/bulletproof-security/403.php
    
    RewriteEngine On
    RewriteBase /
    
    # For example disable .log files
    <IfModule mod_rewrite.c>
      RewriteCond %{REQUEST_URI} (\.log)
      RewriteRule .* - [F,L]
    </IfModule>
    
    # Redirecting rules HTTP to HTTPS
    <IfModule mod_rewrite.c>
      RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
      RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
      RewriteCond %{HTTPS} off
      RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}  [R=301,L]
    </IfModule>

    1) https://example.com/test.log -> Works fine.
    2) http://example.com/test.log -> Doesn’t work.

    Please have a look at my screenshot:

    • This topic was modified 3 years, 1 month ago by rpost.
    • This topic was modified 3 years, 1 month ago by rpost.

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author AITpro

    (@aitpro)

    RewriteCond %{REQUEST_URI} (\.log)
    RewriteRule .* - [F,L]

    The way you are using this code above it will always generate a 403 error since the F flag = forbidden. The ErrorDocument directive is basically a “built-in” redirect. So you would just add a path to a logging file. ie the BPS 403.php error logging file. So basically it looks like you are doing something redundant that does not need to be done with your code above.

    • This reply was modified 3 years, 1 month ago by AITpro.
    • This reply was modified 3 years, 1 month ago by AITpro.
    Plugin Author AITpro

    (@aitpro)

    I think I misunderstood what you were asking. I think you simply are trying to get an HTTP redirect to go to HTTPS? Try the Rewrite htaccess code below first. You may need to create a DNS CNAME record to get HTTP URL’s to redirect to HTTPS URL’s. Example: CNAME www.forum forum.ait-pro.com, but that would depend on how your SSL Certificate TLD is setup. Anyway these are all the things you need to consider to figure out the problem.

    Try this code below > https://forum.ait-pro.com/forums/topic/wordpress-ssl-htaccess-code-rewrite-ssl-rewritecond-server_port/#post-7233

    # WP REWRITE LOOP START
    RewriteEngine On
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    RewriteBase /
    RewriteCond %{HTTPS} !=on
    RewriteCond %{SERVER_PORT} ^80
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
    RewriteRule ^index\.php$ - [L]
    • This reply was modified 3 years ago by AITpro.
    Plugin Author AITpro

    (@aitpro)

    Since this is not a BPS plugin question and it’s been a while since you responded then I’m going to resolve this thread.

    Also wanted to mention that if you do want to use the BPS plugin as an htaccess file manager and editor you would use the BPS Custom Code feature to create customized htaccess files.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘ErrorDocument doesn’t work’ is closed to new replies.