0

I am using Apache 2.2. Now in that, I have done some changes: if any request on my port I want to send back http status code 404.

Now I have 3 ports running on my Apache Server: 8808,8809,8810. If the request comes on the third port I want to send back to the user 404 http status code.

Currently I have this in my httpd.conf

RedirectMatch 404 ".*"
ErrorDocument 404 "Not Found"

Now how can I do this for a specific port, if the request comes in to that port?

0

I think this will work with a virtualhost:

<VirtualHost *:8808>
    RedirectMatch 404 ".*"
    ErrorDocument 404 "Not Found"
</VirtualHost>

repeat that for other ports, obviously.

Note that if you've already got a <VirtualHost *:*> or something in your apache configuration, you will need to change that -- otherwise it will be valid for this port as well, and you'll have overlapping virtual hosts (which will almost certainly not do what you want).

0

Create a virtualhost for all your ports:

<VirtualHost *:8808>
    some directives here
</VirtualHost>
<VirtualHost *:8809>
    some directives there
</VirtualHost>
<VirtualHost *:8810>
    RedirectMatch 404 ".*"
    ErrorDocument 404 "Not Found"
</VirtualHost>

Take a look here for more relevant info, it may help too.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.