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
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?
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.