ozdon Posted November 16, 2006 Share Posted November 16, 2006 I am having an issue with the Apache conf file. Here is what I want to do:If a user goes to http://www.site.com/director1/index.html, I would like the apache config file to search the url and if it finds */director1/*, I would like to redirect to a custom Error Document (thus returning a 404). i have tried this, but it does not seem to work at all.<Location ~ "/(director1|director3)/*"> RewriteRule ^.*$ http://www.site.com/ErrorDocument ErrorDocument 404 /ErrorDocument.html </Location> Quote Link to comment Share on other sites More sharing options...
remmargorp Posted November 16, 2006 Share Posted November 16, 2006 Try<LocationMatch "/(director1|director3)/"> RewriteRule ^.*$ http://www.site.com/ErrorDocument ErrorDocument 404 /ErrorDocument.html</LocationMatch> Quote Link to comment Share on other sites More sharing options...
ozdon Posted November 16, 2006 Author Share Posted November 16, 2006 Yeah, I see where you are coming from, but for some reason I do not think that the "LocationMatch" or "Location" can understand "RewriteRule ^.*$ http://www.site.com/ErrorDocument".I thought of another solution, I could just do RedirectMatch ^/(director1|director2)/.*$ /point/to/errDoc.htmlBut the only downside is that now the status code is a 302, and I would perfer a 404.....Any ideas? Quote Link to comment Share on other sites More sharing options...
remmargorp Posted November 16, 2006 Share Posted November 16, 2006 RedirectMatch allows for status to be passed.The syntax for RedirectMatch is as follows (if I remember):RedirectMatch status regex URLWhere status is optional and default is 302RedirectMatch 404 ^/(director1|director2)/.*$ /point/to/errDoc.htmlI also just found this in the apache docs for mod_rewrite:Although rewrite rules are syntactically permitted in <Location> sections, this should never be necessary and is unsupported. Quote Link to comment Share on other sites More sharing options...
ozdon Posted November 16, 2006 Author Share Posted November 16, 2006 I really appreciate your help, but i am now getting this error when i do that.Syntax error on line 1196 of /usr/local/apache2.0.55/conf/httpd.conf:Redirect URL not valid for this status Quote Link to comment Share on other sites More sharing options...
remmargorp Posted November 16, 2006 Share Posted November 16, 2006 Maybe you can't actually pass 404 as a status... I'll have to check it out later Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.