codeigniter删除index.php表单网址 [英] codeigniter remove index.php form url

查看:72
本文介绍了codeigniter删除index.php表单网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



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



因为我必须在codeigniter中使用不同的项目。所以第二个项目我已上传到子文件夹中。



.htaccess

 #原始

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

#modify
RewriteEngine on

RewriteCond $ 1!^(index\.php | resources | robots\ txt.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]

以上程序的基本网址。因此,我将在此程序中对其进行更改,使其可在子文件夹中使用。

解决方案

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

 #BEGIN WordPress 
< IfModule mod_rewrite.c>
RewriteEngine在
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



它正在工作。 >

I am trying to remove "index.php" from url in Codeigniter. I know how to remove index.php from base url like this example.com/controller.

But i don't know how to remove "index.php" in sub folder like example.com/folder/index.php/controller

Because i have to different projects in codeigniter. so second project i have uploaded in sub folder.

.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]

The above program for base url. So what i will change in this program it work on sub folder.

解决方案

Write this code in your .htaccess file

# 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 : example.com/folder/index.php/contorller

after above code no need to write index.php

it's working..

这篇关于codeigniter删除index.php表单网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆