404 오류 사용자 지정 오류 페이지 사용.htaccess
3262 단어 Access
Introduction
We've all seen the dreaded Error 404 message - the result of broken links and mistyped URLs. You've probably been on some websites where the error pages are customised with their own logo and message, and I'm sure you'll agree that it looks far more professional than the standard one.
In this article we'll show you how to use Apache's .htaccess file to make your own customised error 404 pages.
Create the .htaccess file
Create a new text file on your computer, and call it "htaccess.txt". Enter the following lines:
<Files .htaccess>
order allow,deny
deny from all
</Files>
ErrorDocument 404 http://www.youdomain.com/error404.htm
The first part stops people viewing your .htaccess file. The second part tells Apache to redirect any 404 errors to the file "error404.htm".
Create the 404 page
Now you need to create the 404 page. Make a new web page called "error404.htm"and enter "This is my 404 page". Enter it a few dozen times, as Internet Explorer won't display it unless the file is over 512 bytes.
Once it's done, login to your webspace with your FTP client, and create a new folder called "errordocs". Upload the file "error404.htm"to this directory. Upload "htaccess.txt"to the root of your webspace and rename it to ".htaccess"ó there's no .txt at the end, no name in front, just ".htaccess". If the file seems to vanish don't worry, some FTP clients don't display it ó the file's still there.
Trying it out
Now you need to see if it works. Type the URL of your website in your browser and add a random file name at the end. Something like "http://www.yoursite.com/dgsgdgsdgdsgg.htm".
If everything has worked properly, you should now be seeing your custom error message. If not, then it's possible your web host doesn't allow you to have your own .htaccess files. You may want to contact them and ask.
If it worked then you can now make a proper 404 page. You can have your own images, text, in fact anything else you can have in a normal web page. The best 404 pages have the site logo and a few simple lines explaining what's happened. If you have a site search, you could put that on it too in order to help visitors find what they're looking for.
Taking it further
There's several other error documents that you might wish to customise.
400 - Bad request 401 - Authorization Required 403 - Forbidden directory 404 - Page not found 500 - Internal Server Error
For each one you want to use, simply add a line to your .htaccess file and create the corresponding page.
<Files .htaccess>
order allow,deny
deny from all
</Files>
ErrorDocument 403 http://www.youdomain.com/error403.htm
ErrorDocument 404 /error404.htm
ErrorDocument 500 /error405.htm
from: http://www.totallyphp.co.uk/custom-error-pages-using-htaccess
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Access 사용 요약DataSource만 지정하면 됩니다.Data 디렉토리.Asp.net의 이런 방식은 우리로 하여금 상대적인 경로로 데이터베이스 파일의 위치를 지정하는 데 매우 편리하게 할 수 있다.여기서 Provider는 Oledb...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.