更动Apache默认起始(索引)页面:DirectoryIndex

更改Apache默认起始(索引)页面:DirectoryIndex

Apache默认索引页面是index.html,修改成其他文件需要修改httpd.conf文件:

?

  
  

   
   # # DirectoryIndex: sets the file that Apache will serve if a directory # is requested. # 


   
   <

   
   IfModule 

   
   dir_module

   
   >


   
    DirectoryIndex index.html index.php 


   
   </

   
   IfModule

   
   >


  
  

?

可在Apache根目录建立一个负责跳转的index.php,比如输入IP地址直接跳转到http://ip/myweb/

?

  
  

   
   <?

   
   php 


   
   if

   
    (

   
   !

   
   empty

   
   (

   
   $_SERVER

   
   [

   
   '

   
   HTTPS

   
   '

   
   ]) 

   
   &&

   
    (

   
   '

   
   on

   
   '

   
    

   
   ==

   
    

   
   $_SERVER

   
   [

   
   '

   
   HTTPS

   
   '

   
   ])) { 


   
   $uri

   
   =

   
    

   
   '

   
   https://

   
   '

   
   ; } 


   
   else


   
    { 


   
   $uri

   
   =

   
   '

   
   http://

   
   '

   
   ; } 


   
   $uri

   
   .=

   
    

   
   $_SERVER

   
   [

   
   '

   
   HTTP_HOST

   
   '

   
   ]; 


   
   header


   
   (

   
   '

   
   Location: 

   
   '

   
   .

   
   $uri

   
   .

   
   '

   
   /myweb/

   
   '

   
   ); 


   
   exit

   
   ; 


   
   ?>


   
    


  
  

?

更动Apache默认起始(索引)页面:DirectoryIndex

相关文章:

你感兴趣的文章:

标签云: