**This post has two parts**
-- Part 1 --
example.com/friend1/*.*
Like DOS,
dir *.* in the directory "friend1",
that kind of
everything and anything.
So no matter what the path is if it is or contains "friend1" I don't want Apache to apply the rewrite.
example.com/friend1/ <-- file exists with file extension match so not rewritten
example.com/friend1/1 <-- if 404, is rewritten, don't want that
example.com/friend1/1.gif <-- if 404, is rewritten, don't want that
example.com/friend1/a <-- if 404, is rewritten, don't want that
example.com/friend1/z.zip <-- if 404, is rewritten, don't want that
example.com/friend1/404-file.html <-- if 404, is rewritten, don't want that
example.com/friend1/wt24t42t42t <-- if 404, is rewritten, don't want that
I don't want
any URL in that directory to be rewritten period.
Instead I want that directory to use it's own HTTP 404 designated file.
In example.com/friend1/.htaccess I set...
ErrorDocument 404 /friend1/404.html
I want his 404 handler to kick in because then the errors with him moving/renaming/deleting files won't show up in my logs. Since Apache won't stop rewriting all of his URL's that aren't found every single 404 error in his directory is showing up in my log because the rewrite it catching those errors. I want to prevent that and have his own 404 handler deal with the errors. HTTP 200 files (e.g. his images, mp3's, etc) aren't rewritten as they match the file extension rules so there's no problem there unless he uploads a file with an extension that isn't given an exception. So it's missing files that don't exist that aren't found on the file system and thus Apache rewrites the URL to my own site's index.php at the public root that pulls my CMS and logs it as an error.
Maybe a linear example...
Time line...
1.) REQUEST:
example.com/friend1/a-404-file.mp3.
2.) Server does not find a file, rewrites to example.com/index.php because we don't know how to prevent *.* (DOS style) from being rewritten for the entire directory.
3.) My CMS is called when example.com/index.php is accessed in rewrite.
4.) My CMS does not find the request path in the database.
5.) My CMS logs the request as a reject (MP3 files are only stored on my domain in the file system, since nothing would be found in the database it's automatically rejected).
6.) Media player user agent shows up in my reject log.
So my reject log is being flooded with
his 404 errors.
Perhaps asking my question in a different context?
Can I instead of adding a *.* exception to the directory somehow simply override the Error 404.html file for his directory?
In example I have a few cases where I use a subdirectory (e.g. blog and forums) to handle requests differently. Now that I think of it I
could use that however it would be a weird/unintended context...
A) example.com/.htaccess
B) example.com/friend1/.htaccess
-- Part 2 --
So I gained some insight after a couple things fell in to place...I still have the problem though now I have something I can focus on.
So I used the same rewrite in the main inside the subdirectory .htaccess with some success after testing a 404 URL. However when I tested it with the test 404 URL that I've been using it still was using my rewrite and after a moment I realized some of the characters don't quite look right.
example.com/friend1/some-404.mp3 <-- uses the desired 404
example.com/friend1/Friend1%25mp20-%25mp20Mother.mp3 <-- pulls my main site's rewrite
So I removed the % characters from that second URL and the 404 error page I set in the subdirectory .htaccess file to 404.html worked!
The problem for me is that looking at my reject logs at greater depth and looking at the origins of the IP addresses that are making these oddball requests is that they're bots based out of China. *sigh*
So I know if the character % appears in the URL it throws off the exception and my rewrite rule kicks in. Is there something I can do to force the exception to work for his subdirectory when odd characters are still present? Thanks for all the replies.
- John