【问题标题】:CodeIgniter .htaccess index.php rewrite not working on sub directory levelCodeIgniter .htaccess index.php 重写在子目录级别不起作用
【发布时间】:2016-02-09 09:18:59
【问题描述】:

我正在使用 codeigniter 开发一个新网站,昨天我将它托管在一个新服务器上。它与主页(landing page URL: http://(domain-name)/(folder-name))完美配合。但是,如果我尝试访问任何其他页面,它会显示:

404 Not Found 错误“在此服务器上未找到请求的 URL /(文件夹名称)/注册。”

URL: http://(domain-name)/(folder-name)/Register

我正在使用routes.php 所以,

注册 =

$route['Register'] = 'register/index';

我已经把index.php改成了

$config['index_page'] = '';

改变了

$config['uri_protocol'] = 'AUTO';

而我的.htaccess

RewriteEngine on  
RewriteCond $1 !^(index\.php|public|\.txt)   
RewriteCond %{REQUEST_FILENAME} !-f  
RewriteCond %{REQUEST_FILENAME} !-d  
RewriteRule ^(.*)$ folder-name/index.php?$1 [L]  

请帮我解决这个问题。 感谢和问候

【问题讨论】:

  • 您使用的是哪个版本的 CI?
  • 我的 CI 版本是 2.2.0
  • 从 3.X 版开始,Codeigniter 严格检查文件名。所有的类名(控制器和模型)和相关文件都应该在 Ucfirst 中严格命名!确保你已经这样做了。你不会在 mac 中得到这样的错误,因为文件系统是不区分大小写的,但是 linux 会抛出!尝试根据严格的约定更改文件名

标签: php apache .htaccess codeigniter mod-rewrite


【解决方案1】:

通过清除您的 .htaccess 尝试以下行。

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php?/$0 [QSA,L]
</IfModule>

它对我有用。希望这样也能解决您的问题。

【讨论】:

    【解决方案2】:

    尝试使用以下链接编辑 htaccess 文件

    http://addictors.in/remove-index-php-from-url-in-codeigniter/

    【讨论】:

      猜你喜欢
      • 2015-03-31
      • 2017-02-21
      • 1970-01-01
      • 1970-01-01
      • 2015-11-20
      • 1970-01-01
      • 1970-01-01
      • 2011-10-09
      • 1970-01-01
      相关资源
      最近更新 更多