大网数据广告活动
网站运营与故障问答

Apache ErrorDocument based on folder

· 52CE 我爱测

I'm using XAMPP with Apache 2.4.18 . My client have 3 divisions of their work (they do 3 different things so they have 3 divisions inside of the website). So the URL is like this: clientName.domain/workDivision X I have this fold…

问题原文

原帖链接 · Jimmy Adaro · CC BY-SA 3.0

I'm using XAMPP with Apache 2.4.18.

My client have 3 divisions of their work (they do 3 different things so they have 3 divisions inside of the website).

So the URL is like this: clientName.domain/workDivisionX

I have this folder structure:

htdocs
L clientName
  L .htaccess
  L workDivision1
    L css
    L img
    L js
    L errors
      L 404.php
      L 500.php
    L //other files
  L workDivision2
    L css
    L img
    L js
    L errors
      L 404.php
      L 500.php
    L //other files
  L workDivision3
    L css
    L img
    L js
    L errors
      L 404.php
      L 500.php
    L //other files

The design between these 3 divisions looks so different that I need to show different style and content in the error documents.

So, if I go to: clientName.domain/workDivision1/asdfghjk (resulting in HTTP 404), I should be able of display the workDivision1's 404 error page. Same with other divisions.

Is there any chance to show the ErrorDocument base on the division folder? Not necessarily must be done through htaccess. I'm open to alternatives.

已采纳解答

原帖链接 · MrWhite · CC BY-SA 3.0

One way to do this is to simply define a separate ErrorDocument for each directory. Either create a .htaccess file in each subdirectory with the appropriate directive, or use <Directory> containers in your server config.

For example, in htdocs/clientName/workDivision1/.htaccess:

ErrorDocument 404 /clientName/workDivision1/errors/404.php

etc.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2016-10-20)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。