简体   繁体   English

Codeigniter删除/index.php/class

[英]Codeigniter removing /index.php/class

I've moved all of a local intranet site onto a new server with a new dns. 我已将所有本地Intranet站点移至具有新dns的新服务器上。 Everything seems to be working fine after changing setting and config files. 更改设置和配置文件后,一切似乎工作正常。
The only thing that is annoying me is that I can't get rid of the 唯一让我烦恼的是我无法摆脱

http://intranet/trunk/index.php/class on the old server 旧服务器上的http://intranet/trunk/index.php/class

http://intrenet/trunk/class 

worked fine, but now it throws up 工作正常,但现在抛出

The requested URL /trunk/class/ was not found on this server. 在此服务器上找不到请求的URL / trunk / class /。

But as I said, works fine when using the /index.php/class . 但是正如我所说,使用/index.php/class时效果很好。 This should be fixable in the .htdocs (which I have put in the trunk folder, is that wrong?) 这应该可以在.htdocs中修复(我已经把它放在主文件夹中了,对吗?)

I've changed all the codeigniter configs too. 我也更改了所有codeigniter配置。

First make sure that URL-Rewriting (mod_rewrite) is enabled in your web server. 首先,请确保您的Web服务器中启用了URL重写(mod_rewrite)。 Then create a .htaccess file in your htdocs directory with the below code. 然后,使用以下代码在htdocs目录中创建一个.htaccess文件。

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

and also edit config.php and remove the index.php 并编辑config.php并删除index.php 在此处输入图片说明

I had the same problem and i resolved with this .htaccess file 我遇到了同样的问题,并且使用此.htaccess文件解决了

# Mod Rewrite active
<IfModule mod_rewrite.c>
    # Set base path
    RewriteEngine On
    RewriteBase /Workspace/codeigniter/

    # Denied access to system directory
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    # Denied access to application directory
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    # Check for error request
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

# Mod Rewrite inactive
<IfModule !mod_rewrite.c>
    ErrorDocument 404 /index.php
</IfModule> 

Remember to set 记得设定

$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';

in the config/config.php file and to change the path of the "RewriteBase" var. 在config / config.php文件中,并更改“ RewriteBase”变量的路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM