【问题标题】:How to remove “index.php” in codeigniter's in server如何删除服务器中codeigniter中的“index.php”
【发布时间】:2013-09-04 01:59:58
【问题描述】:

在 Codeigniter 中从我的 URL 中删除 index.php 时遇到问题。

我的直播网址:直播服务器中的“http://ec2-174-129-44-226.compute-1.amazonaws.com”问题

本地也有问题

我尝试过使用下面的代码。

重写引擎开启

RewriteCond $1 !^(index.php|resources|robots.txt)

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d`

重写规则 ^(.*)$ index.php/$1 [L,QSA]

但它会在本地 wamp 服务器中引发错误

“内部服务器错误

服务器遇到内部错误或配置错误,无法完成您的请求。

请联系服务器管理员 admin@localhost 并告知他们错误发生的时间,以及您可能执行的任何可能导致错误的操作。

服务器错误日志中可能会提供有关此错误的更多信息。”

请.....帮助..我...谢谢....

【问题讨论】:

  • 你的问题是?还有一个小问题:你为什么首先认为这样一段代码会完成你正在寻找的事情? (请同时检查您的问题的格式=)
  • 你试过在 RewriteEngine on 之后添加“RewriteBase /your_project_folder/”吗?

标签: php codeigniter-2


【解决方案1】:

打开 config.php 并进行以下替换

$config['index_page'] = "index.php" 

替换为

$config['index_page'] = ""

$config['uri_protocol'] = "AUTO" 

替换为

$config['uri_protocol'] = "REQUEST_URI"

HTACCESS

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

【讨论】:

    【解决方案2】:

    试试看。

    打开 config.php 并进行以下替换

    $config['index_page'] = "index.php"
    to
    $config['index_page'] = ""
    

    在某些情况下,uri_protocol 的默认设置无法正常工作。 只需更换 $config['uri_protocol'] =“自动” 经过 $config['uri_protocol'] = "REQUEST_URI"

    HTACCESS

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

    【讨论】:

    • 但它会触发 Internal Server Error 服务器遇到内部错误或配置错误,无法完成您的请求。请联系服务器管理员 admin@localhost 并告知他们错误发生的时间,以及您所做的任何可能导致错误的事情。服务器错误日志中可能会提供有关此错误的更多信息。
    • 尝试查看您的主虚拟主机配置。如果未设置,请添加“AllowOverride All”。这是我最初的问题。
    猜你喜欢
    • 2018-01-27
    • 2014-01-07
    • 2014-11-25
    • 2013-07-31
    • 2015-03-11
    • 2017-12-21
    • 2014-02-10
    • 2011-01-18
    • 1970-01-01
    相关资源
    最近更新 更多