简体   繁体   中英

Redirect subdirectory to 404 page with status code

I am trying to redirect a subset of pages that have been removed from a website to a specific 404 page using htaccess.

I currently have this rule in my htaccess:

RewriteRule ^de/Engineering.*$ /error/ [R,L]

This works, but the url changes in the browser to error, which is bad for search engine bots, and the returned code is 302. I would like the url to remain the same (silent redirect) and the status code to change. The target page returns a correct 404 code so I need to pass that back through.

/error/文档已经返回404状态代码时,您可以省略R标志

RewriteRule ^de/Engineering.*$ /error/ [L]

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