当 URL 包含任何带有托管服务参数的控制器或方法时,Codeigniter 服务器错误
Codeigniter server error when the URL contains any controller or method with arguments on a hosting service
我确实使用 codeigniter 框架在本地主机上开发了我的网站,然后我从 www.web.com 获得了域名和托管服务。
我将我的网站上传到服务器根文件夹中的 htdocs 文件夹。
这是结构:
- /
- cgi-bin
- htdocs
- 申请
- 系统
- js
- css
- img
- index.php
- .htaccess
假设我的域是 www.example.com 并且它指向 htdocs 文件夹。
当我键入 www.example.com 时,它成功打开了我的主页,没有出现错误。
但是当我尝试打开任何其他页面时,例如 www.example.com/products 或 www.example.com/products/browse_product/2 它加载页面成功但在每个页面的末尾总是出现此错误
我的 .htaccess 文件:
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/system.*
RewriteRule ^(.*)$ index.php?/ [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?/ [L]
我确实通过执行此操作解决了问题:
/* config.php 文件 */
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
/* routes.php 文件 */
$route['default_controller'] = "home";
$route[''] = "home/index";
$route['home'] = "home/index";
$route['404_override'] = '';
/* 主 .htaccess 文件 */
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
我确实使用 codeigniter 框架在本地主机上开发了我的网站,然后我从 www.web.com 获得了域名和托管服务。
我将我的网站上传到服务器根文件夹中的 htdocs 文件夹。 这是结构:
- /
- cgi-bin
- htdocs
- 申请
- 系统
- js
- css
- img
- index.php
- .htaccess
假设我的域是 www.example.com 并且它指向 htdocs 文件夹。
当我键入 www.example.com 时,它成功打开了我的主页,没有出现错误。
但是当我尝试打开任何其他页面时,例如 www.example.com/products 或 www.example.com/products/browse_product/2 它加载页面成功但在每个页面的末尾总是出现此错误
我的 .htaccess 文件:
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/system.*
RewriteRule ^(.*)$ index.php?/ [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?/ [L]
我确实通过执行此操作解决了问题:
/* config.php 文件 */
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
/* routes.php 文件 */
$route['default_controller'] = "home";
$route[''] = "home/index";
$route['home'] = "home/index";
$route['404_override'] = '';
/* 主 .htaccess 文件 */
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>