【问题标题】:My Project could not able to view in online我的项目无法在线查看
【发布时间】:2016-08-08 04:20:51
【问题描述】:

我的项目无法在线运行(cpanel) "https://www.sample.com/folder"

但我这样提供我的网址意味着工作
"https://www.sample.com/folder/index.php/controller_name"

我想要“sample.com/folder/controller_name

如何解决这个问题。我希望我的 URL 像第一个一样

我的配置文件信息

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

我的Route文件是这样的,这里有什么问题吗。

$route['default_controller'] = "pages/home";
$username = '(:any)';
$route['404_override'] = '';
$route['sample/([0-9]+)'] = "sample/index/$1";
$route['pages/profile'] = "pages/profile"; 
$route['pages/userList'] = "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";

【问题讨论】:

  • 这看起来不像是一个开发问题,而且您提供的信息非常少。您可能想在 serverfault.com 上提问
  • 添加了关于@Quasimodo's clone 的url详细信息

标签: codeigniter url routes


【解决方案1】:

首先你改变你的 config.php

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

$config['index_page'] = '';

改变

$config['base_url'] = 'https://www.sample.com/';

和您的 HTACCESS 文件

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

【讨论】:

  • 你也改变了你的 htaccess 文件
  • 改变你的 $config['base_url'] = 'sample.com';在你的 config.php 文件中
  • 在 Apache 中启用 mod_rewrite
  • 抱歉,@Aslam 没有任何效果,krishnakumar
【解决方案2】:

将“https://www.sample.com/folder”中的.htaccess 文件更改为

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

【讨论】:

  • .htacess 文件的放置位置.. 在域 (sample.com) 下或 (sample.com/folder) 下
  • 在 (https.www.sample.com) 下是否需要 .htacess ?
  • .htaccess文件放入(sample.com/folder)@JanaSan
  • 试过 没用 @jatin 。现在我在我的 linux 服务器中检查 mod_rewrite,但它没有显示(如何启用它?)
  • stackoverflow.com/questions/869092/…希望这将有助于解决您的问题。
【解决方案3】:

在你的配置文件中你需要改变

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

$config['index_page'] = '';

然后改变

$config['base_url'] = '';

$config['base_url'] = 'https://www.sample.com/folder/';
//you need to put the folder

然后在你的 .htacces //把它放在像 /var/www/foler/ 这样的根路径中

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

【讨论】:

  • 我再次在上面尝试过,但没有任何反应。我在同一个位置
猜你喜欢
  • 2020-07-25
  • 1970-01-01
  • 1970-01-01
  • 2021-07-29
  • 1970-01-01
  • 2020-10-13
  • 2017-08-07
  • 2021-12-12
  • 2014-09-24
相关资源
最近更新 更多