繁体   English   中英

从 Codeigniter URL 中删除 index.php 不起作用

[英]Removing index.php from Codeigniter URLs not working

这个问题已经回答了几次,但答案对我不起作用。 我最近重新安装了 Windows 10,所以 XAMPP 安装是一个干净的安装,但它曾经在我的上一台 PC 上工作。 rewrite_module 已启用

When I go to http://localhost , my app redirects me to http://localhost/login , but it says 404 until I type http://localhost/index.php/login

我的config.php

$config['base_url'] = 'http://localhost';
$config['index_page'] = '';

在codeigniter根文件夹的.htaccess文件中:

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

我尝试过的解决方案:

答案 1

答案 2 (这给了我“找不到对象!”错误)

答案 3

答案 4

我修改了 .htaccess 文件添加了这一行:

RewriteBase /YOURPROJECTFOLDER/

所以:

RewriteEngine on
RewriteBase /ShopCaseCodeigniter/
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA] 

更改 apache 服务器 httpd.conf 中的设置

AllowOverride All -> AllowOverride FileInfo

暂无
暂无

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

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