首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从Mandriva的index.php中删除CodeIgniter中的URL

从Mandriva的index.php中删除CodeIgniter中的URL
EN

Stack Overflow用户
提问于 2015-02-15 12:07:29
回答 2查看 2.8K关注 0票数 0

我开发了一个在Windows上使用CodeIgniter的项目。该项目在XAMPP (Windows)和(更新后的服务器上的.htaccess )上工作得很好。我想使用开放曼德利瓦作为发展的目的。如果我使用index.php运行控制器,它就能工作。

我尝试了许多.htaccess规则的例子,链接。但是控制器没有加载。

我试过:无法从index.php URL中删除CodeIgniterCodeIgniter从url中删除index.php这个外部链接以及许多其他链接。

Windows机器上的.htaccess代码

代码语言:javascript
复制
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA] 

Linux主机服务器上的.htaccess代码

代码语言:javascript
复制
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/system.*
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?/$1 [L]

两人都没有在开放曼德利瓦上工作。

.htaccess路径

代码语言:javascript
复制
/srv/www/html/ci/

这一页提供:

404错误,并且找不到对象!

我的项目的文件系统路径是

代码语言:javascript
复制
/srv/www/html/ci/application/controllers/ 

在浏览器上:

代码语言:javascript
复制
localhost/ci/branch 

如果我添加类似的index.php,项目就能工作

代码语言:javascript
复制
localhost/ci/index.php/branch

它与http服务器配置有任何关系吗?我需要安装任何软件包吗。此外,我还尝试了一些apache重写引擎的命令。但我得到的错误是未知的命令。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-02-15 16:46:46

检查重写引擎是否为已启用

如果没有,则启用重写引擎并重新启动服务器。

代码语言:javascript
复制
sudo a2enmod rewrite
sudo service apache2 restart

代码语言:javascript
复制
/etc/httpd/conf/httpd.conf - for Mandriva
/etc/apache2/apache2.conf  - for Ubuntu

AllowOverride None更改为AllowOverride All

代码块:

代码语言:javascript
复制
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
#   AllowOverride FileInfo AuthConfig Limit
#
AllowOverride All

重新启动Apache(httpd)服务。

config.php或其他地方不需要进行任何更改。

.htaccess代码:

代码语言:javascript
复制
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
票数 2
EN

Stack Overflow用户

发布于 2015-02-15 12:41:03

请试用以下方法:

代码语言:javascript
复制
RewriteEngine on
RewriteBase /ci/
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [L,QSA]

然后,在config.php

代码语言:javascript
复制
$config['index_page'] = "";
$config['uri_protocol'] = "REQUEST_URI";

请确保您的.htaccess位于与index.php相同的目录中。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28525870

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档