简体   繁体   中英

Can I send a different header than 404 on my "custom 404' page in an apache server?

Example:

On the custom 404 script/page I want to check the requested uri against a list and redirect the user to that page if the requested uri doesn't exist.

I may send a 301 or a 302 depending on the content in the uri.

EDIT:

Here's the new idea: put the 404 error document in a new directory eg /errors/. In that directory put the .htaccess with 4500 301 redirects. That way the 301 redirects are not processed on every root page, but only when a page is not found.

Please comment if this makes sense.

That many redirects i would definitely put in the httpd.conf/apache.conf. I would also suggest to redirect with a 301 status code (instead of delivering a 404 and then redirect as you outlined in your question). That said - there is one exceptional case: if there is a chance to map those 4500 redirects using regexp - you could switch back to htaccess again...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM