Author |
Message |
n3pla
New Member


Joined: Mar 02, 2012
Posts: 6
|
Posted:
Sat Mar 10, 2012 3:11 am |
|
I had to change my ErrorDocument section of my htaccess. This is a new installation everything works fine with the changes. However, I fear a possible looping problem for a 404 error. Here is the original htaccess:
Code:RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) modules.php?name=ErrorDocuments&file=404&rs=$1 [NC,L,R]
ErrorDocument 400 /modules.php?name=ErrorDocuments
ErrorDocument 401 /modules.php?name=ErrorDocuments
ErrorDocument 403 /modules.php?name=ErrorDocuments
ErrorDocument 406 /modules.php?name=ErrorDocuments
ErrorDocument 500 /modules.php?name=ErrorDocuments
|
and changed it to the
Code:
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteRule (.*) modules.php?name=ErrorDocuments&file=404&rs=$1 [NC,L,R]
ErrorDocument 400 /modules.php?name=ErrorDocuments
ErrorDocument 401 /modules.php?name=ErrorDocuments
ErrorDocument 403 /modules.php?name=ErrorDocuments
ErrorDocument 404 /modules.php?name=ErrorDocuments
ErrorDocument 500 /modules.php?name=ErrorDocuments
|
Note: I removed the 406 error simply because the server I am using gives me 5 html files that I could modify to make them look like my web site these are for the same 5 errors I chose to reflect in my htaccess. When I used the original code the 404 error did not function. I could not think of a way to test the other errors, but the 404 continued to default to the 404.shtml file. What changes could I try to revert back to the original RewriteCond type error handler for 404 errors. I want to be sure there is no chance at looping. |
|
|
|
 |
Palbin
Site Admin

Joined: Mar 30, 2006
Posts: 2583
Location: Pittsburgh, Pennsylvania
|
Posted:
Sat Mar 10, 2012 9:33 am |
|
This one may take some time to answer because I am of sure how many people are familiar with the workings of this. |
_________________ "Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan. |
|
|
 |
n3pla

|
Posted:
Thu Mar 15, 2012 6:45 pm |
|
Here is what I was able to determine so far...
Code:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) modules.php?name=ErrorDocuments&file=404&rs=$1 [NC,L,R]
ErrorDocument 400 /modules.php?name=ErrorDocuments
ErrorDocument 401 /modules.php?name=ErrorDocuments
ErrorDocument 403 /modules.php?name=ErrorDocuments
ErrorDocument 406 /modules.php?name=ErrorDocuments
ErrorDocument 500 /modules.php?name=ErrorDocuments
|
is correct. However at the top of the .htaccess document you should uncomment the Options line as shown below...
Code:
# 'Options +FollowSymLinks' is required for use of mod_rewrite.
# Can be commented out if causes errors, see notes above.
# For security reasons, Option followsymlinks cannot be overridden.
Options +SymLinksIfOwnerMatch
|
However this does not work yet. Two things needed to be added to the .htaccess document, at least on my server it was needed... add them as follows just below the Options line at the top of the document...
Code:
# 'Options +FollowSymLinks' is required for use of mod_rewrite.
# Can be commented out if causes errors, see notes above.
# For security reasons, Option followsymlinks cannot be overridden.
Options +SymLinksIfOwnerMatch
RewriteEngine On
RewriteBase /
|
Your RewriteBase line might need to be different, after the changes, forcing an 404 error produced the correct response.
BTW I did restore the 406 Error handling after getting the 404 Error handling functional I decided to return the code back to the way it was formerly written except for the addition of the two lines...
Code:
RewriteEngine On
RewriteBase /
|
Hope this helps someone else... the source of my information was the following web page...
[URL]http://www.askapache.com/htaccess/modrewrite-tips-tricks.html[URL] |
|
|
|
 |
n3pla

|
Posted:
Thu Mar 15, 2012 6:47 pm |
|
Oops
Only registered users can see links on this board! Get registered or login! |
|
|
|
 |
n3pla

|
Posted:
Thu Mar 15, 2012 6:52 pm |
|
P.S. I have noticed that the Error Handling for Raven Nuke is not correctly reflecting the original URL that was causing the error. The data in the reflected shows the entire URL used to generate the error message rather than the URL of the "missing/deleted" page. The code should be rewritten to use the "rs" variable rather than the path of the error document. |
|
|
|
 |
Guardian2003
Site Admin

Joined: Aug 28, 2003
Posts: 6799
Location: Ha Noi, Viet Nam
|
Posted:
Fri Mar 16, 2012 12:31 am |
|
Not sure why you need to explicitly add the RewriteEngine On since it should already be on if using the default htaccess file
Are you actually using RN version 2.3 ??
Sorry I cannot help you more with this but I have never used this module, I use my own custom error documents. |
|
|
|
 |
n3pla

|
Posted:
Tue Mar 20, 2012 6:35 am |
|
|
|
 |
montego
Site Admin

Joined: Aug 29, 2004
Posts: 9457
Location: Arizona
|
Posted:
Tue Mar 20, 2012 6:58 am |
|
I do agree that some installations (not very many actually) require the explicit turning rewrite on and fewer still need the base set to "/".
I'm with Guardian, that I do not use this feature as I really do not want the extra overhead of an actual module especially if I'm being pummeled with automated exploit checking tools. I prefer to log all the errors in a file and then once every few hours check to see if there is anything in that file, and if so, send the contents out in an email....
Edited: Forgot to mention that I also moved this thread into the 2.5 forum. |
_________________ Only registered users can see links on this board! Get registered or login!
Only registered users can see links on this board! Get registered or login! |
|
|
 |
n3pla

|
Posted:
Tue Mar 20, 2012 7:02 am |
|
One other thing every example I have seen of someone using .htaccess they added the two lines I used in my .htaccess file. Maybe "just in case" these lines were not added in the servers configuration, but for what ever reason I followed their example and it worked.
Once I examine the ErrorDocument module, I should be able to figure out how to rewrite the module to use the rs variable used by the 404 handling code. I will then change the error handlers in the .htaccess file for the other error codes so they also used the rs variable to send the correct data to the module.
Presently only the 404 error handing in the .htaccess file sets the rs variable in the URL that calls the ErrorDocument module. ErrorDocument module presently does not USE the rs variable. It is therefore necessary to modify both to have the ErrorDocument module display the proper data.
I remember using PHPNuke, and doing something similar with error handling code and .htaccess for that... would not be the first time I modded php to make things more suitable for my tastes. |
|
|
|
 |
Guardian2003

|
Posted:
Tue Mar 20, 2012 10:08 am |
|
n3pla wrote: |
Note: I removed the 406 error simply because the server I am using gives me 5 html files that I could modify to make them look like my web site these are for the same 5 errors I chose to reflect in my htaccess. When I used the original code the 404 error did not function. |
That is a little confusing.
If you want to use error pages provided by your hosting provider you should be doing something like
Code:
ErrorDocument 400 /400.html
ErrorDocument 401 /401.html
ErrorDocument 403 /403.html
... etc
|
As you know, ErrorDocument is Apache's htaccess command to intercept HTTP header response codes, followed by a space and the three digit error code, followed by another space and the url to forward to.
Code:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) /modules.php?name=ErrorDocuments&file=404&rs=$1 [NC,L,R]
|
Those three lines are a special case. Essential it takes the requested filename and adds it to the $1 variable in the rewrite rule so the Errordocument module can process the requested file name.
If you also have Code:
ErrorDocument 404 /modules.php?name=ErrorDocuments
| you should delete it as this will negate the previous rule and rewrite condition for processing a 404 header response code. |
|
|
|
 |
|