apache phpオープン擬似静的

6262 ワード

  apache     httpd.conf
  
#LoadModule rewrite_module modules/mod_rewrite.so
   #  。     ,       , apache   mod_rewrite   

  
<Directory "D:/ApacheServer/web">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.2/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    AllowOverride None

    #
    # Controls who can get stuff from this server.
    #
    Order allow,deny
    Allow from all

</Directory>
 
AllowOverride None    AllowOverride All  apache   .htaccess   

  apache   

         PHP          .htaccess   

  .htaccess        

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule index.html$ index.php
    RewriteRule index-([1-9]+[0-9]*).html$ index.php?p=$1
    RewriteRule ([a-z]{1,})-([0-9]{1,}).html$ index.php?action=$1&id=$2
</IfModule>

  :
RewriteEngine          ,on   ,off   。

RewriteRule            ,$               ,            。$+               ,
              ,           $_GET['p']   $_GET['action']  $_GET['id']    
$1                      ,    ,$2            
RewriteRule                 ()    


       test
     index.php        
<?php
if ($_GET ['p']) {
    echo "p : " . $_GET ['p'];
}

if ($_GET ['action']) {
    echo "action : " . $_GET ['action'];
}

if ($_GET ['id']) {
    echo "id : " . $_GET ['id'];
}
?>

       
http://localhost/test/index.html
http://localhost/test/index-99.html
http://localhost/test/page-18.html

     http://localhost/test/index.php   
    
http://localhost/test/index.html             
http://localhost/test/index-99.html       p : 99
http://localhost/test/page-18.html        action : pageid : 18