errordocument

Index.php as custom error page

邮差的信 提交于 2019-12-11 01:06:29
问题 I'm using Apache 2.2.X and PHP 5.2.X (installed as Apache module) to build a new website and I would like to read your suggestions about how I'm trying to handle server errors. I was thinking about using the same file of my homepage (/index.php) to show custom error messages. This is my .htaccess setup: ErrorDocument 400 /index.php?error=400 ErrorDocument 401 /index.php?error=401 ErrorDocument 403 /index.php?error=403 ErrorDocument 404 /index.php?error=404 ErrorDocument 500 /index.php?error

right order of rewrite rules in an htaccess file

╄→尐↘猪︶ㄣ 提交于 2019-12-07 07:23:41
I need to have : http://www.example.com/v1/my-project/ redirected to http://example.com/my-project/ so : (1) remove the www from the http_host RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC] RewriteRule ^(.*)$ http://example.com/$1 [R=301,L] (2) remove the 'v1/' part of the request_uri RewriteCond %{REQUEST_URI} ^/v1/(.*)$ [NC] RewriteRule . %1 [R=301,L] (3) I also want to redirect all 404 to the homepage. ErrorDocument 404 / (4) Finally, all my documents actually reside in a "v2/" folder which hosts the current active website, but i don't want "v2" in the url, just "/" RewriteCond %{REQUEST

Creating an error page for a subdomain that doesn't exist

浪尽此生 提交于 2019-12-06 11:23:15
问题 I've got a number of subdomains on one of my sites. When someone goes to a subdomain that doesn't exist, I want to redirect to a 404 page on my main domain. noexist.example.com --> example.com/404.php?subdomain=noexist (or without the query string if HTTP_REFERRER can give me that info) I'm running LAMP on a VPS with cPanel installed. I can edit the DNS Zone file for the domain via WHM. 回答1: After a few hours ticketing my server's support center, I finally got wildcard subdomains set up. Now

.htaccess ErrorDocument使用方式

不羁岁月 提交于 2019-12-04 04:50:18
网站服务器在不能响应使用者需求下,会产生各种错误讯息,这些错误讯息均有一个代码,我们来瞧瞧这代码所代表的意义: 响应代码 响应内容 代表意义 401 Authorization failed 授权失败。用户输入的账号密码无法得到授权。 403 Forbidden 访问控制机制拒绝使用者的请求,也就是说你不可以读取这个档案。 404 File not found 被要求的网页不存在于这个服务器上,找不到档案。 500 Internal Server Error 服务器内部错误;可能是网站服务器或PHP出了问题。 501 Not Implemented 服务器不了解数据传递的方式。 503 Service Unavailable 这个服务器目前正在处理太多的服务要求。 【图1 找不到档案时显示方式】 如果我们想要自定义错误讯息呢?要设定错误页,请在.htaccess中输入: ErrorDocument 错误代码 /网站根目录开始的文件夹/文件名 例如当使用者找不到网页时,会产生404错误的回传,请在.htaccess内加入以下数据: ErrorDocument 404 /error/notfound.htm 当使用者在浏览不存在的网页时,就会自动转向至localhost(或你的网站ip)/error/notfound.htm, 【图2 自定义找不到档案时显示的内容】

htaccess errordocument 404 and pass url to path

一笑奈何 提交于 2019-12-02 10:43:19
问题 How can I pass the 404'd URL to my 404.html page using .htaccess For example, if I visit an invalid page: /user/123 RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d ErrorDocument 404 /?404.php?error_path={???} ^ =========================================^ Resulting in a 404 redirect to /404.php?error_path=/user/123 回答1: ErrorDocument is not part of mod_rewrite and that is invalid. Is this what your looking for? RewriteEngine On RewriteCond %{REQUEST

htaccess errordocument 404 and pass url to path

﹥>﹥吖頭↗ 提交于 2019-12-02 05:07:21
How can I pass the 404'd URL to my 404.html page using .htaccess For example, if I visit an invalid page: /user/123 RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d ErrorDocument 404 /?404.php?error_path={???} ^ =========================================^ Resulting in a 404 redirect to /404.php?error_path=/user/123 ErrorDocument is not part of mod_rewrite and that is invalid. Is this what your looking for? RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d Rewriterule ^(.*) /404.php?error_path=$1 [R=301,L] On apache 2

.htaccess show 404, 403, 500, error pages via PHP

梦想的初衷 提交于 2019-11-29 17:38:06
How can I make .htaccess display errors from a PHP file? I mean when I search a non-existing file .htaccess should show me an error page from error.php, but error.php needs a parameter with the error code. NOTE: .htaccess should show the error directly on the current url without redirecting. Can I do this or it is impossible? Are there any other ways? You're looking for ErrorDocument . In your .htaccess specify the codes you want to handle, like: ErrorDocument 403 /error.php ErrorDocument 404 /error.php ErrorDocument 500 /error.php And in error.php, handle the error codes like: <?php $code = $

Single ErrorDocument directive to catch all errors (.htaccess)

南楼画角 提交于 2019-11-29 02:49:39
Is there something like a wildcard directive to catch all possible errors and deal with them in a single custom error page? ErrorDocument 404 /error.php?code=404 ErrorDocument 403 /error.php?code=403 ... ErrorDocument NNN /error.php?code=NNN #possible use of RegExp? I know I probably won't be dealing with a lot of custom error pages here, but I'm curious about this. That is not possible. You need to have a ErrorDocument directive for each status code you want to handle differently than with the default error handler. Rather than passing in the error status code, you can pick it up in your

.htaccess show 404, 403, 500, error pages via PHP

风流意气都作罢 提交于 2019-11-28 12:24:58
问题 How can I make .htaccess display errors from a PHP file? I mean when I search a non-existing file .htaccess should show me an error page from error.php, but error.php needs a parameter with the error code. NOTE: .htaccess should show the error directly on the current url without redirecting. Can I do this or it is impossible? Are there any other ways? 回答1: You're looking for ErrorDocument . In your .htaccess specify the codes you want to handle, like: ErrorDocument 403 /error.php

Single ErrorDocument directive to catch all errors (.htaccess)

青春壹個敷衍的年華 提交于 2019-11-27 17:06:55
问题 Is there something like a wildcard directive to catch all possible errors and deal with them in a single custom error page? ErrorDocument 404 /error.php?code=404 ErrorDocument 403 /error.php?code=403 ... ErrorDocument NNN /error.php?code=NNN #possible use of RegExp? I know I probably won't be dealing with a lot of custom error pages here, but I'm curious about this. 回答1: That is not possible. You need to have a ErrorDocument directive for each status code you want to handle differently than