【问题标题】:Getting rid of index.php from mywebsite.com/admin从 mywebsite.com/admin 中删除 index.php
【发布时间】:2018-04-17 11:55:29
【问题描述】:

我有一个使用 Codeigniter 框架用 PHP 开发的网站。

我在其中包含了.htaccess 文件,它适用于我的所有网页,但我没有得到 index.php,但是当我输入我的管理 url 时,它是

mywebsite.com/admin

它去

www.mywebsite.com/index.php/admin

index.php 仅在我尝试访问我的管理页面时出现。

我尝试了很多来摆脱它,我什至在管理控制器和视图文件夹中都包含了 .htaccess 文件的副本,但没有任何效果。欢迎任何建议。

【问题讨论】:

  • 在 config.php 中我已经完成了 $config['index_page'] = '';已经,但在管理员案例中不起作用。
  • 显示您的查看链接
  • 你会在上面的链接中得到完整的答案
  • 在我的情况下,我尝试做链接中的内容,但它不能解决我的问题。

标签: php .htaccess codeigniter


【解决方案1】:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

确保它应该位于根文件夹并在 config.php 中设置您的base_url。 例如 $config['base_url'] = 'localhost/home'

【讨论】:

    【解决方案2】:

    添加以下更改,

    application/config/config.php

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

    .htaccess

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

    【讨论】:

      猜你喜欢
      • 2014-05-04
      • 2014-09-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-14
      • 2014-10-28
      • 2012-06-15
      • 2013-02-27
      相关资源
      最近更新 更多