CodeIgniter:从 URL 中删除 'index.php'

CodeIgniter: removing 'index.php' from URL

我之前已经回答过这个问题,而且还自己贴出了答案。我尝试了大部分已回答的问题,但仍然没有用。第一个问题是关于 .htaccess 文件的放置,我应该把它放在应用程序文件夹中还是放在里面?下一个问题是 'How should I remove the index.php from URL'?

.htaccess 代码:

RewriteEngine On
RewriteCond  !^(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';

如果可能,还建议提供有关如何自定义 TankAuth 或任何其他更容易的身份验证库的详细教程。我正在使用 Windows 8.1 和 Wamp 服务器。

如有任何建议或帮助,我们将不胜感激。

在您的 .htaccess 文件中使用它:

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

将 ./ 放在 index.php 重写规则之前。

或者这个

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


有关详细信息,请参阅 link:https://ellislab.com/expressionengine/user-guide/urls/remove_index.php.html

试试这个 htaccess 工作正常 windows 7 和 8.1 和 xampp

确保将 .htaccess 放在 主目录 而不是应用程序文件夹中。

Options +FollowSymLinks
Options -Indexes

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

配置

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

更多 htaccess https://github.com/riwakawebsitedesigns/htaccess_for_codeigniter

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/ [L] 
</IfModule>

应用程序 > 配置 > config.php

$config['base_url'] = '';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';

肯定有用。

我想这对你有帮助,

.htaccess

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/ [L]

在config.php

    $http = 'http'.((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 's' : '').'://';
    $newurl = str_replace('index.php', '', $_SERVER['SCRIPT_NAME']);
    $config['base_url'] = "$http".$_SERVER['SERVER_NAME'].''.$newurl;
    $config['modules_locations'] = array('http://localhost/astrido_admin/application/' . 'modules/');

$config['index_page'] = '';

谢谢

config.php 中更改此

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

.htaccess(注意:这应该放在应用程序文件夹之外)

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/ [L] 
</IfModule>

Note: There are lot of duplicate question. So before Ask New Question please check your dropdown menu(its comes with when you start typing title of your question) whether its exist or answer provided.

1.config.php

$config['index_page'] = 'index.php';     change  to     $config['index_page'] = '’;

2.Create.htaccess 文件

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/ [L]

对我有用,我顺便用v2.2.6

  • 在与 index.php
  • 相同的目录中创建 .htaccccess
  • 修改index_page和base_url中的值/application/config/config。php

这是它的样子

picture image link