gpt4 book ai didi

apache - Codeigniter web.config 或 .htaccess index.php 在子目录中重写

转载 作者:行者123 更新时间:2023-12-04 15:31:44 25 4
gpt4 key购买 nike

我的网站文件夹结构如下...

Application Root
|- administration
|--|- application
|--|- system
|--|- index.php
|--|- web.config
|
|- application
|- system
|- index.php
|- web.config

两个 CI框架安装在这里。
  • 网站根
  • 管理文件夹

  • 这里我说的是administration子文件夹。

    我的 web.config URL Rewrite就像下面一样。
    <rules>
    <rule name="Rewrite to index.php">
    <match url="index.php|robots.txt|images|test.php" />
    <action type="None" />
    </rule>
    <rule name="Rewrite CI Index">
    <match url=".*" />
    <conditions>
    <add input="{REQUEST_FILENAME}" pattern="css|js|jpg|jpeg|png|gif|ico|htm|html" negate="true" />
    </conditions>
    <action type="Rewrite" url="index.php/{R:0}" />
    </rule>
    </rules>

    问题是,如果我删除 index.php来自 $config['index_page']site_root/administration/application/config/config.php , 任何 Controller 功能显示 404 页面未找到 .网站根 web.config实际上这样做。

    我要删除 index.php从子目录内的 URL。

    1. 怎么通过web.config ?

    2. 如何通过.htaccess 执行?

    我找到了 THIS ,但没有得到答复。

    最佳答案

    我有同样的问题,但它现在工作。这对我有用。傅旭的回答很好,但不太奏效。所以,如果你对他的代码进行以下修改,它可能对你有用,就像对我一样。
    我变了<rule name="Rewrite Administration Index"><rule name="Rewrite Administration Index" stopProcessing="true">
    然后我改变了<match url="administration/(.*)" /><match url="^administrator/(.*)$" ignoreCase="true"/>
    然后<conditions><conditions logicalGrouping="MatchAll">
    并且还修改了这个<add input="{REQUEST_FILENAME}" pattern="css|js|jpg|jpeg|png|gif|ico|htm|html" negate="true" /><add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />

    这是完整的代码:

    <rule name="Rewrite Administration Index" stopProcessing="true">
    <match url="^administration/(.*)$" ignoreCase="true"/>
    <conditions logicalGrouping="MatchAll">
    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
    </conditions>
    <action type="Rewrite" url="administration/index.php/{R:1}" />
    </rule>

    <rule name="Rewrite CI Index" stopProcessing="true">
    <match url="^(.*)$" ignoreCase="true" />
    <conditions logicalGrouping="MatchAll">
    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
    </conditions>

    <action type="Rewrite" url="index.php/{R:1}" appendQueryString="true" />
    </rule>

    我希望这对你有用

    关于apache - Codeigniter web.config 或 .htaccess index.php 在子目录中重写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40003236/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com