【问题标题】:Codeiginter product worked well in localserver without index.php but not worked in serverCodeigniter 产品在没有 index.php 的本地服务器中运行良好,但在服务器中无法运行
【发布时间】:2016-08-22 17:02:24
【问题描述】:

我在codeiginiter中创建了一个项目

这是在没有 index.php (localhost/sample) 的本地服务器上工作的 但是当我升级到在线服务器(cpanel linux)时,默认控制器只能工作,其他下一页 URL 不起作用..(https://sample/nextpage

如果我给 index.php 意味着工作 (https://sample/index.php/nextpage)

我想删除 index.php ,请帮帮我..

我的配置文件

$config['index_page']   = 'index.php';
$config['uri_protocol'] = 'REQUEST_URI';

我的 route.php 文件

$route['default_controller'] = "pages/home";
$route['pages/profile'] = "pages/profile"; 
$route['creators'] = "pages/userList";
$route[$username] = "pages/userList/userview/$1"; 

$route['translate_uri_dashes'] = FALSE;
$route['404_override'] = '';

我的 .htaccess 文件

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L] 
Options All -Indexes 

提前致谢,

施鲁提。

【问题讨论】:

    标签: .htaccess codeigniter url codeigniter-3


    【解决方案1】:

    尝试使用以下代码更改 .htaccess 文件的代码

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

    【讨论】:

    • 非常感谢!... 周日我的项目启动日期即将到来.. 你只救了我。非常感谢..
    【解决方案2】:

    更改 .htaccess 文件

      RewriteEngine On
      RewriteBase /name of project folder 
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule ^(.*)$ index.php?/$1 [L]
    

    【讨论】:

    • 我的在线服务器上没有项目文件夹..在public_html下上传
    • 不是问题,你可以跳过那一行。
    • 您使用的标志不正确...请参阅:httpd.apache.org/docs/current/rewrite/flags.html
    • 看不懂那个链接
    • 好的..现在跳过第二行,让我知道它是否适合你
    【解决方案3】:

    试试这个

    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
    RewriteCond $1 !^(index\.php|img|css|public|tmp|download|javascript|rte|document|xajax_js|robots\.txt)
    

    【讨论】:

      【解决方案4】:

      请联系您的托管服务提供商并检查 mod_rewrite 模块是否启用?

      【讨论】:

      • 由@sarvagna 回答
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-06-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-08
      • 1970-01-01
      • 2020-02-25
      相关资源
      最近更新 更多