【问题标题】:My codeiginter project not worked without index.php in online如果没有 index.php,我的 codeiginter 项目无法在线运行
【发布时间】:2016-08-20 01:18:21
【问题描述】:

我的 Codeigniter 项目在 localhost 中运行良好(我使用的是 linux Cpanel)

https://localhost/project/profile

但如果链接中没有 index.php,它就无法在线工作

https://domainname.in/index.php/profile

.htaccess 文件

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

还有我的 route.php 文件

$route['default_controller'] = "pages/home";
$route['404_override'] = '';
$route['pages/profile'] = "pages/profile"; 
$route['creators'] = "pages/userList";
$route['auth/logout'] = "auth/logout";
$route['auth'] = "auth/logout";
$route['auth/login'] = "auth/login";
$route['auth/register'] = "auth/register";
$route['pages/post'] = "pages/post";
$route[$username.'/about'] = "pages/menus/about";
$route[$username.'/credibility'] = "pages/menus/credibility";
$route[$username.'/release'] = "pages/menus/release";
$route[$username.'/jobs'] = "pages/menus/jobs";
$route[$username] = "pages/userList/userview/$1";   

【问题讨论】:

标签: .htaccess codeigniter cpanel


【解决方案1】:

请尝试一下。希望它会起作用。

使用您的根 .htaccess.txt 文件进行更新

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

【讨论】:

  • htaccess 文件在主文件夹或应用程序文件夹中的位置
  • .htaccess.text 文件未显示在服务器中。您需要在本地主机或电脑中更新,然后需要在服务器中上传。请以这种方式尝试。这是我们服务器中的工作版本。
  • 仍有问题。 Index.php 未从 URL 中删除
  • 流程这一步:
    打开 config.php 并执行以下操作将
    $config['index_page'] = "index.php"
    替换为
    $config['index_page'] = ""
    在某些情况下,uri_protocol 的默认设置不能正常工作。只需将
    $config['uri_protocol'] ="AUTO" 替换为 $config['uri_protocol'] = "REQUEST_URI"
    然后检查您的 apache 是否启用了重写 mod
  • 我已经改变了这个。以及如何检查重写模式是否启用.. 我在 xampp 窗口的 php_info() 中看到了它的显示.. 我的站点链接 streetrelease.in 请访问
【解决方案2】:

在您的项目文件夹中创建 .htaccess 文件,我希望它可以工作。

RewriteEngine on
RewriteBase /projectfoldername/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|js|img|css|captcha|robots\.txt)
RewriteRule ^(.*)$ /projectfoldername/index.php/$1 [L]

【讨论】:

    猜你喜欢
    • 2016-09-21
    • 2017-11-05
    • 2021-12-08
    • 2017-02-01
    • 2019-10-03
    • 2017-06-14
    • 1970-01-01
    • 1970-01-01
    • 2014-07-11
    相关资源
    最近更新 更多