• 修改apache配置文件去除thinkphp url中的index.php


    修改apache配置文件去除thinkphp url中的index.php

    例如你的原路径是 http://localhost/test/index.php/index/add
    变成 http://localhost/test/index/add

    如何去掉index.php呢?
    1、httpd.conf配置文件中加载了mod_rewrite.so模块 //在APACHE里面去配置
    #LoadModule rewrite_module modules/mod_rewrite.so把前面的警号去掉

    2、AllowOverride None 将None改为 All
    Options None 改为 Options All
    注意:在APACHE里面去配置 (注意其他地方的AllowOverride也统统设置为ALL)

    <Directory "D:/wampp/apache/cgi-bin">
    AllowOverride none 改 AllowOverride ALL
    Options None 改 Options All
    Order allow,deny
    Allow from all
    </Directory>

    <Directory "cgi-bin">
    #AllowOverride None
    #Options None
    AllowOverride all
    Options all
    Order allow,deny
    Allow from all
    </Directory>
    ------------------------------------
    配置了别名的例子:
    Alias /wnwweb "d:/wamp/www/wnwweb/"
    <Directory "d:/wamp/www/wnwweb/">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride all
    Order Deny,Allow
    Deny from all
    Allow from 127.0.0.1
    </Directory>

    3、确保URL_MODEL设置为2,在项目的配置文件里写
    return Array(
    //其他配置
    'URL_MODEL' => '2',
    );

    4 、.htaccess文件必须放到跟目录下
    代码如下:
    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
    </IfModule>

  • 相关阅读:
    MVC部分视图
    windows服务
    mvc中seeeion和cook的用法
    @Html.Raw()用法和Html.ActionLink的用法总结
    FileStream类的使用(文件流)
    简单工厂和工厂模式对比
    项目案例【Net Core】如何注入多个服务实现类
    快速查找所有存储过程/触发器中是否包含某个字符串
    TortoiseGit安装与配置
    C# 中==与Equals方法比较
  • 原文地址:https://www.cnblogs.com/zdz8207/p/apache-thinkphp-url-rewrite.html
Copyright © 2020-2023  润新知