# Rewrites and derps

**URL:** <https://forums.interworx.com/t/rewrites-and-derps/14085>\
**Category:** General Discussion\
**Tags:** apache, error-redirect, error-pages\
**Created:** [October 18, 2016, 12:47am UTC](https://forums.interworx.com/t/rewrites-and-derps/14085 "2016-10-18T00:47:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Keiro](https://forums.interworx.com/letter_avatar_proxy/v4/letter/k/8e8cbc/32.png) [@Keiro](https://forums.interworx.com/u/Keiro)\
**Post date:** [October 18, 2016, 12:47am UTC](https://forums.interworx.com/t/rewrites-and-derps/14085/1 "2016-10-18T00:47:48Z")

</div>

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:

```auto

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:

```auto

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:

```auto

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:

```auto

[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?

---

<div class="post-metadata">

**Author:** ![Keiro](https://forums.interworx.com/letter_avatar_proxy/v4/letter/k/8e8cbc/32.png) [@Keiro](https://forums.interworx.com/u/Keiro)\
**Post date:** [October 18, 2016, 1:09am UTC](https://forums.interworx.com/t/rewrites-and-derps/14085/2 "2016-10-18T01:09:57Z")

</div>

[QUOTE=Keiro;29148]  
[…]  
Any idears, folks?[/QUOTE]

Turns out I finally hit on a combination that worked.

```auto

ErrorDocument 404 https://mypastebin.com/vice/404.php
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

```

---

<div class="post-metadata">

**Author:** ![d2d4j](https://forums.interworx.com/user_avatar/forums.interworx.com/d2d4j/32/16_2.png) [@d2d4j](https://forums.interworx.com/u/d2d4j)\
**Post date:** [October 18, 2016, 1:55am UTC](https://forums.interworx.com/t/rewrites-and-derps/14085/3 "2016-10-18T01:55:21Z")

</div>

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
