.htaccess - 如何获取 .htaccess 文件的当前路径
问题描述
我想在 .htaccess 文件中设置 404 错误文件的路径,而不是每次更改域时都在其中输入域。
例如 :
这是正常的代码ErrorDocument 404 http://www.example.com/404.php
我想将其设置为ErrorDocument 404 404.php
我的意思是 widthout 域 url 。
.htaccess 中是否有像$_SERVER['HTTP_HOST']
php 一样的变量来获取域 url?
当我将 404 代码设置为ErrorDocument 404 404.php
它的显示空白页面时,其中的文本仅像“404.php”。
谢谢你的帮助^_^。
解决方案
这就是我在 .htaccess 文件中使用的内容。希望能帮助到你。
# This redirects browsers that experience a 404 error (Not Found) (and others listed)
# to the file "error.php" located in the same directory as your .htaccess file.
ErrorDocument 400 /error.php
ErrorDocument 401 /error.php
ErrorDocument 403 /error.php
ErrorDocument 404 /error.php
ErrorDocument 500 /error.php
推荐阅读
- glsl - 如何以不同的颜色绘制立方体每个面的每个角?
- asp.net-core-3.0 - 在 .Net core 3.0 控制台应用程序中使用 HttpClient 上传文件
- python - 如何查找一行不包含指定字符串短语的时间?
- python - 试图连接多个 csv 文件,目录错误?
- javascript - 在 javascript / typescript 中将 Element 转换为 HTMLElement
- objective-c - 如何获取所有可用的 Paper Feed 以及如何在 NSPrintInfo obj 中更改它
- rest - REST - 更新实体的所有属性时的 PUT 或 PATCH
- c# - c#检测当前文本所在的行?
- php - 使用带有 PHP 的简单 REST API 在我的 SQL 中存储纬度和经度时面临的问题
- sql - 如何在 PostgreSQL 中使用相同的引用命名不同的列?