[英]Removing index.php from URL in CodeIgniter on Mandriva
我开发了一个在Windows OS上使用CodeIgniter的项目。 该项目在XAMPP(Windows)和Linux托管服务器(服务器上更新的.htaccess可以正常工作)上正常运行。 我想将Open Mandriva用于开发目的。 如果我使用index.php运行控制器,它将起作用。
我尝试了许多.htaccess规则示例,链接。 但是控制器未加载。
我尝试过: 无法从CodeIgniter URL删除index.php , CodeIgniter从URL和此外部链接以及许多其他链接删除index.php 。
Windows机器上的.htaccess代码
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代码
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/system.*
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?/$1 [L]
两者都无法在Open Mandriva上使用。
.htaccess路径
/srv/www/html/ci/
该页面提供:
404错误,找不到对象!
我项目的文件系统路径是
/srv/www/html/ci/application/controllers/
在浏览器上:
localhost/ci/branch
如果我像这样添加index.php,项目将正常工作
localhost/ci/index.php/branch
它与http服务器配置有关系吗? 我是否需要安装任何软件包。 我也尝试了一些命令为Apache重写引擎。 但是我收到错误作为未知命令。
检查是否启用了重写引擎。
如果不是,请启用重写引擎并重新启动服务器。
sudo a2enmod rewrite
sudo service apache2 restart
去
/etc/httpd/conf/httpd.conf - for Mandriva
/etc/apache2/apache2.conf - for Ubuntu
将AllowOverride None
更改为AllowOverride All
代码块:
# 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代码:
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
请尝试以下操作:
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
:
$config['index_page'] = "";
$config['uri_protocol'] = "REQUEST_URI";
请确保您的.htaccess
与index.php
位于同一目录中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.