gpt4 book ai didi

php - codeigniter 删除 index.php 表单 url

转载 作者:行者123 更新时间:2023-12-02 04:38:32 24 4
gpt4 key购买 nike

我正在尝试从 Codeigniter 的 url 中删除“index.php”。我知道如何从 example.com/controller 这样的基本 url 中删除 index.php。

但我不知道如何删除子文件夹中的“index.php”,例如 example.com/folder/index.php/controller

因为我必须在 codeigniter 中处理不同的项目。所以我在子文件夹中上传了第二个项目。

.htaccess

#original
#RewriteEngine on
#RewriteCond $1 !^(index\.php|images|robots\.txt)
#RewriteRule ^(.*)$ index.php/$1 [L]

#modify
RewriteEngine on

RewriteCond $1 !^(index\.php|resources|robots\.txt)

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php?/$1 [QSA,L]

RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

上面的基本 url 程序。所以我将在这个程序中改变它在子文件夹上的工作。

最佳答案

将此代码写入您的 .htaccess 文件

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /folder/index.php [L]
</IfModule>

# END WordPress

示例:example.com/folder/index.php/contorller

上面的代码之后就不用写index.php了

它正在工作..

关于php - codeigniter 删除 index.php 表单 url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39641333/

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