|
| 作者:佚名 电脑来源:中国站长站 点击数: 更新时间:2007-12-13 |
|
.htaccess文件是非常有用的,下面一篇介绍: 天添资源网 • Part 1 – Introduction介绍 天添资源网 • Part 2 - .htaccess Commande命令 www.ttzyw.com • Part 3 - Password protection密码保护 天添资源网 Part 1 – Introduction介绍 天添资源网 Introduction 介绍 天添资源网 In this tutorial you will find out about the .htaccess file and the power it has to improve your website. Although .htaccess is only a file, it can change settings on the servers and allow you to do many different things, the most popular being able to have your own custom 404 error pages. .htaccess isn't difficult to use and is really just made up of a few simple instructions in a text file. www.ttzyw.com@com 从本指南中,您可以学习到有关.htaccess文档及其功能,用以优化您的网站。尽管.htaccess只是一个文档,但它可以更改服务器的设置,允许您做许多不同的事情,最流行的功能是您可以创建自定义的“404 error”页面。.htaccess 并不难于应用,只是在一个text文档中添加几条简单的指令而已。 天添资源网 Will My Host Support It? 我的主机支持它吗? www.ttzyw.com@com This is probably the hardest question to give a simple answer to. Many hosts support .htaccess but don't actually publicise it and many other hosts have the capability but do not allow their users to have a .htaccess file. As a general rule, if your server runs Unix or Linux, or any version of the Apache web server it will support .htaccess, although your host may not allow you to use it. www.ttzyw.com 这可能很难用简单的答案来回答。许多主机支持.htaccess但实际上并不会明确声明,许多其他类型的主机有能力但并不允许他们的用户使用.htaccess文档。作为一般性的规则,如果你的主机使用Unix或Linux系统,或任何版本的Apache网络服务器,它一般来说是支持.htaccess的,尽管你的主机服务器可能不允许你使用它。 www.ttzyw.com A good sign of whether your host allows .htaccess files is if they support password protection of folders. To do this they will need to offer .htaccess (although in a few cases they will offer password protection but not let you use .htaccess). The best thing to do if you are unsure is to either upload your own .htaccess file and see if it works or e-mail your web host and ask them. 天添资源网 你的主机是否允许.htaccess,很好的一个标志是它是否支持文件夹的密码保护。为此,他们将提供.htaccess支持(尽管少数情况下他们提供密码保护功能但不允许你使用.htaccess)。如果你不确定,最好的办法一是上传你自己的.htaccess文档看看是否有用,二是e-mail给你的主机服务商询问。 天添资源网 What Can I Do? 我该怎么做? www.ttzyw.com@com You may be wondering what .htaccess can do, or you may have read about some of its uses but don't realise how many things you can actually do with it. www.ttzyw.com 你可能疑惑.htaccess到底能做些什么,或者你可能曾知道它的一些功能但并不真正了解你实际到底可以用它来做多少事情。 天添资源网 There is a huge range of things .htaccess can do including: password protecting folders, redirecting users automatically, custom error pages, changing your file extensions, banning users with certian IP addresses, only allowing users with certain IP addresses, stopping directory listings and using a different file as the index file. 天添资源网 .htaccess可以做大量范围的事情,包括:文件夹密码保护、用户自动重新指向、自定义错误页面、变更你的文件扩展名、屏蔽特定的用户IP地址、只允许特定的IP地址、停止目录表以及使用其他文件作为index文件。 www.ttzyw.com@com Creating A .htaccess File 创建一个.htaccess文档 天添资源网 Creating a .htaccess file may cause you a few problems. Writing the file is easy, you just need enter the appropriate code into a text editor (like notepad). You may run into problems with saving the file. Because .htaccess is a strange file name (the file actually has no name but a 8 letter file extension) it may not be accepted on certain systems (e.g. Windows 3.1). With most operating systems, though, all you need to do is to save the file by entering the name as: www.ttzyw.com^com 创建.htaccess文档也许会给你带来几个问题。写文档很容易,你只需要在文字编缉器(例如:写字板)里写下适当的代码。然后,你可能会遇到保存文档的困难,因为.htaccess是一个古怪的文件名(文档事实上没有文件名,只有一个由8个字母组成的扩展名),一些系统(例如windows 3.1)无法接受这样的文件名。在大多数的操作系统中,你需要做的是将文档保存成名为: 天添资源网 ".htaccess" (包括引号)。如果这也不行,你需要将其命名为其他的名字(例如htaccess.txt),再将其上传到服务器上,此后你就可以利用FTP软件来重命名它了。 天添资源网 Warning 警告 www.ttzyw.com@com Before beginning using .htaccess, I should give you one warning. Although using .htaccess on your server is extremely unlikely to cause you any problems (if something is wrong it simply won't work), you should be wary if you are using the Microsoft FrontPage Extensions. The FrontPage extensions use the .htaccess file so you should not really edit it to add your own information. If you do want to (this is not recommended, but possible) you should download the .htaccess file from your server first (if it exists) and then add your code to the beginning. 天添资源网 在使用.htaccess之前,我必须给你一些警告。尽管在服务器上使用.htaccess绝对不太可能给你带来任何麻烦(如果有些东西错了,它只是没效用罢了),但如果你使用Microsoft FrontPage Extensions你就需要小心些。FrontPage Extensions使用了.htaccess,因此你不能编辑它,加入你自己的信息。如果你需要(并不推荐,但是可能)你应该先从服务器上下载.htaccess文档(如果存在),之后在前面加上你的代码。 天添资源网 Custom Error Pages 自定义错误页 www.ttzyw.com The first use of the .htaccess file which I will cover is custom error pages. These will allow you to have your own, personal error pages (for example when a file is not found) instead of using your host's error pages or having no page. This will make your site seem much more professional in the unlikely event of an error. It will also allow you to create scripts to notify you if there is an error (for example I use a PHP script on Free Webmaster Help to automatically e-mail me when a page is not found). 天添资源网 我想介绍的.htaccess第一个应用是自定义错误页面,这使得你可以拥有自己的、个性化的错误页面(例如找不到文件时),而不是你的服务商提供的错误页或没有任何页面。这会让你的网站在出错的时候看上去更加专业。你还可以利用脚本程序在发生错误的时候通知你(例如我使用Free Webmaster Help的PHP脚本程序,当找不到页面的时候自动e-mail给我)。 天添资源网 You can use custom error pages for any error as long as you know its number (like 404 for page not found) by adding the following to your .htaccess file: www.ttzyw.comwww.ttzyw.com@com 任何你知道代码的错误(像404找不到页面),你都可以将其变成自定义页面,要做的只是在.htaccess文件里加入以下一段: 天添资源网 ErrorDocument errornumber /file.html 例如,如果我的根目录下有一个nofound.html文档,我想使用它作为404 error的页面: 天添资源网 ErrorDocument 404 /notfound.html 如果文件不在网站的根目录下,你只需要把路径设置为: 天添资源网 ErrorDocument 500 /errorpages/500.html |
| 电脑录入:不落尘埃 责任编辑:不落尘埃 |
| 【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口】 |
| ■■相 关 文 章: | 网站版权与免责声明: |
| 让windows自带的DNS服务支持泛解… DNS的一些相关基础知识 DNS完全解惑问答 Win2000之DNS服务器的设置 深入研究DNS原理 如何在Linux服务器上设置DNS Win 2K动态DNS的安全考虑 |
1、信息来源网络,感谢原创者和原录入者。本站转载其文并不代表赞同其观点或证实其内容。网站所有信息仅供参考,不构成任何之建议、推荐或指引,不能仅凭此信息购药、用药、诊断疾病或开处方,而应以其使用说明书为准,并谨遵医嘱。
2、网站中转载的资料及图片,其版权属原作者或页面内声明的版权人拥有。如果文章的作者或编辑认为不宜上网供大家浏览,或不应无偿使用,请及时用电子邮件或电话通知我们,以便迅速采取适当措施,避免双方造成不必要的经济损失。 |
|
||||||||||