PHP单一入口apache配置和去除index.php

   index : index在互联网上表示网站的默认主页。
一般为 index.html index.htm index.asp index.php;
另外的默认主页也多用default.html;default.htm等。
    RewriteCond : RewriteCond指令定义一条规则条件。在一条RewriteRule指令前面可能会有一条或多条RewriteCond指令,只有当自身的模板(pattern)匹配成功且这些条件也满足时规则才被应用于当前URL处理。
    RewriteRule : 它还可以实现限制特定IP访问网站的功能。比如原本需要http://www.abc.com/read.php?tid=123 通过Rewriterule 变成哦 http://www.abc.com/123.htm也可以访问。
0、这方面在一些博客或者论坛的网站上利用比较多,比如cnbate,比如PHPWIND等一些访问量高又希望友好亲和搜索引擎的站点一般会利用伪静态技术来完成。
Rewri。
    mod_rewrite : mod_rewrite是Apache的一个模块。
    Directory : 用于典型操作,如复制、移动、重命名、创建和删除目录。[1]。

本节内容:
PHP单一入口

在apache配置文件httpd.conf加入,去掉LoadModule rewrite_module modules/mod_rewrite.so前面的“#”号。

内容:
 

代码示例:

DocumentRoot /

<Directory />
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    #AllowOverride All
<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteBase /
  #不显示index.php

  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule  ^/?(.*)$ /index.php?%{QUERY_STRING} [L,NC]
  #RewriteRule ^(.*)$ index.php?$1 [QSA,L]
 </IfModule>
DirectoryIndex index.php index.html index.htm
</Directory>

我的个人设置:
<Directory "D:/xampp/htdocs">
    #
    # 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.4/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks Includes ExecCGI

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

    #
    # Controls who can get stuff from this server.
    #
    Require all granted
<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteBase /
  #不显示index.php

  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule  ^/?(.*)$ /index.php?%{QUERY_STRING} [L,NC]
  #RewriteRule ^(.*)$ index.php?$1 [QSA,L]
 </IfModule>
</Directory>
原文地址:https://www.cnblogs.com/patf/p/5015967.html