简体   繁体   中英

.htaccess redirect subdomain 404 to main domain 404

I'm working with a site that used to use a subdomain to link to an externally hosted blog. This has since been deleted and incorporated into the main site. The subdomain now just houses a .htaccess file with 301 redirects for the blog articles.

I also have a 404 page set up for any other remaining links to the subdomain. The problem is that I want the 404 to be served from the main domain, not the subdomain. Instead of blog.example.com/404, I want to serve www.example.com/404.

Not sure if it matters, but on the server, my subdomain is a folder inside of the main domain: html/ = www.example.com html/blog/ = blog.example.com

  1. Remove any 404 ErrorDocument line from DOCUMENT_ROOT/blog/.htaccess

  2. In your DOCUMENT_ROOT/.htaccess add this line:

    ErrorDocument 404 /blog/404.html

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