网络营销电子商务研究中心  
How to buy the best prescription safety glasses in Canada? Let's study!
Go Back   网络营销电子商务研究中心 > 服务器与数据库 > 服务器环境搭建
User Name
Password
 
FAQ Members List Calendar Cheap Glasses

服务器环境搭建 Windows,Linux,IIS,Apache等服务器配置、安全维护以及PHP和MYSQL运行环境讨论。

Reply
 
Thread Tools Display Modes
  #1   IP: 112.87.17.117
Old 2015-05-21, 07:16 AM
West University Place West University Place is offline
初级会员
 
Join Date: 2008-07-31
Posts: 4
West University Place 现在声名狼藉
Default 通过.htaccess文件设置网站的默认页

网站新建好后,很多新手站长会对网站的默认首页的设置很是烦恼。比如用的是php的程序,默认首页大多是打开的网站根目录里面的“/index.php”文件;若是用asp语言开发的程序,首页打开大多是默认打开"/index.asp";以jsp语言开发的程序,默认打开是“/index.jsp”等等。当然少数空间商的空间控制面板能够支持自定义默认页,但大多是还是不支持。我们都知道,使用静态页面有利于SEO,可很多站长却不知道如何设置。故此小编特写下此文,供各位有需求的站长参考。

1. PHP语言开发的网站设置默认打开静态页面的方法。首先复制如下代码:
<Files ~ "^.(htaccess|htpasswd)$">
deny from all
</Files>
DirectoryIndex index.html index.php
order deny,allow

上面代码的意思是:网站默认打开根目录下文件的顺序。首先是“index.html",若没有该文件,则打开“index.php"。


2. ASP语言开发的网站设置默认打开静态页面的方法。复制下方代码:

<Files ~ "^.(htaccess|htpasswd)$">
deny from all
</Files>
DirectoryIndex index.html index.asp
order deny,allow
上面代码的意思是:当目录中没有“index.html”文件时,默认打开“index.asp”文件。


3. 若果是新手站长,不清楚自己网站的开发环境,又想设置默认打开静态文件时,可以考虑直接使用如下代码。

<Files ~ "^.(htaccess|htpasswd)$">
deny from all
</Files>
DirectoryIndex index.html index.php index.asp index.shtml index.htm index.jsp index.aspx
deny,allow
代码的意思大致和上面差不多,设置的是默认打开网站目录下文件的顺序依次是index.html、index.php、index.asp、index.shtml、index.htm、index.jsp、index.aspx。


4. 根据自己需要选择,复制好相应的代码,粘贴到记事本,保存为".htaccess"文件。然后通过FTP上传到网站的更目录即可。


注意事项
保存时不支持以“.htaccess”文件命名,可以将文件上传到更目录后再改成.htaccess文件名。
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off

Forum Jump

Prescription-glasses.com offers prescription glasses online at discount prices.
All times are GMT +8. The time now is 02:09 AM.


Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.