Announcement

Collapse
No announcement yet.

Rewrites and derps

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Rewrites and derps

    So I've got a customer who came to me for help with his .htaccess.

    He's got a site with a subfolder that has a .htaccess with custom 404s. All good, right? Right. So, what's the problem, then? The problem is that his main site also has .htaccess. The two seem to be interfering with each other and generating an infinite loop.

    Main site .htaccess:

    Code:
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /view.php?id=$1 [L,QSA]
    
    RewriteCond %{HTTPS} !=on
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    
    # END SSL config
    Subfolder .htaccess:

    Code:
    ErrorDocument 404 https://mypastebin.com/vice/404.php
    I also tried with some variations of /404.php, /vice/404.php and full URLs, etc. None of it is working.

    I tried with this:
    Code:
    ErrorDocument 404 https://mypastebin.com/vice/404.php
    RewriteEngine On
    #RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    Obviously, this doesn't quite work and usually results in:

    Code:
    [Tue Oct 18 07:19:32.109454 2016] [core:error] [pid 18255] [client xxx.xxx.xxx.xx:11271] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
    Any idears, folks?
    ★ Ramon Reyes @ EidolonHost
    ★ Shared, Reseller, VPS and Dedicated Servers.
    ★ Need more stuff? Ask us about custom configurations!
    ★ Authorized Blesta and InterWorx License Reseller! See Web Host Licenses

  • #2
    Originally posted by Keiro View Post
    [...]
    Any idears, folks?
    Turns out I finally hit on a combination that worked.

    Code:
    ErrorDocument 404 https://mypastebin.com/vice/404.php
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    ★ Ramon Reyes @ EidolonHost
    ★ Shared, Reseller, VPS and Dedicated Servers.
    ★ Need more stuff? Ask us about custom configurations!
    ★ Authorized Blesta and InterWorx License Reseller! See Web Host Licenses

    Comment


    • #3
      Hi Kerio
      I set error pages directly in httpd.conf, which seems to work lovely without any redirects, and I have had not received any reports from clients that error pages not working as expected.
      I hope that helps
      Many thanks
      John
      Just add at the bottom of httpd.conf, save and restart apache
      ErrorDocument 401 /401.html
      ErrorDocument 403 /403.html
      ErrorDocument 404 /404.html
      ErrorDocument 500 /500.html

      Comment

      Working...
      X