Jump to content

Apache - Filtering URL Help


ozdon

Recommended Posts

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>
Link to comment
https://forums.phpfreaks.com/topic/27481-apache-filtering-url-help/
Share on other sites

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.html

But the only downside is that now the status code is a 302, and I would perfer a 404.....

Any ideas?
RedirectMatch allows for status to be passed.

The syntax for RedirectMatch is as follows (if I remember):

RedirectMatch status regex URL

Where status is optional and default is 302

RedirectMatch 404 ^/(director1|director2)/.*$ /point/to/errDoc.html



I 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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.