• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

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

原作者: [db:作者] 来自: [db:来源] 收藏 邀请
   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>

 


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP之-json转数组,支持多层嵌套json发布时间:2022-07-10
下一篇:
php中explode和implode函数发布时间:2022-07-10
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap