jav*_*irs 6 web-hosting codeigniter-3
我试图在000webhost的共享服务器中使用codeigniter。我上传了包装的内容,如果输入
http://groceriesapi.000webhostapp.com/API/index.php/welcome/
它确实有效。但是,如果我访问:
http://groceriesapi.000webhostapp.com/API/welcome/
您得到404。
我在互联网上读到,应该用.htaccess文件解决此问题。首先,我的文件夹结构中有两个。它是这样的:
public_htm
application
plenty of things
.htaccess
other stuff
.htaccess
Run Code Online (Sandbox Code Playgroud)
我编辑外部.htacces,位于public_html的.htacces看起来像这样:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
Run Code Online (Sandbox Code Playgroud)
现在访问简化的URL(http://groceriesapi.000webhostapp.com/API/welcome/)时,出现500内部服务器错误!
任何线索???
PS:我不在乎URL中间的index.php,但是每当收到错误消息时,整个codeigniter都会崩溃,我不知道出了什么问题..那是一个问题:(
步骤:-1打开文件夹 \xe2\x80\x9capplication/config\xe2\x80\x9d 并打开文件 \xe2\x80\x9cconfig.php\xe2\x80\x9c。在 config.php 文件中找到并替换以下代码。
\n\n//find the below code \n$config[\'index_page\'] = "index.php" \n//replace with the below code\n$config[\'index_page\'] = ""\nRun Code Online (Sandbox Code Playgroud)\n\n步骤:-2转到您的 CodeIgniter 文件夹并创建 .htaccess
\n\nPath:\nYour_website_folder/\napplication/\nassets/\nsystem/\n.htaccess <\xe2\x80\x94\xe2\x80\x94\xe2\x80\x94 this file\nindex.php\nRun Code Online (Sandbox Code Playgroud)\n\n步骤:-3在.htaccess文件中写入以下代码
\n\n<IfModule mod_rewrite.c>\nRewriteEngine On\nRewriteCond %{REQUEST_FILENAME} !-f\nRewriteCond %{REQUEST_FILENAME} !-d\nRewriteRule ^(.*)$ index.php/$1 [L] \n</IfModule>\nRun Code Online (Sandbox Code Playgroud)\n\n步骤:-4在某些情况下,uri_protocol 的默认设置无法正常工作。要解决此问题,只需打开文件 \xe2\x80\x9capplication/config/config.php\xe2\x80\x9c,然后找到并替换以下代码
\n\n//find the below code\n$config[\'uri_protocol\'] = "AUTO"\n//replace with the below code\n$config[\'uri_protocol\'] = "REQUEST_URI" \nRun Code Online (Sandbox Code Playgroud)\n\n这就是全部,但在 wamp 服务器中它不起作用,因为默认情况下 rewrite_module 被禁用,所以我们需要启用它。为此,请执行以下操作
\n\nPS:这个答案是从 CodeIgniter 中逐字复制的,从 url 中删除了 index.php。仅在此发布,因为该问题必须作为赏金的一部分得到回答
\n| 归档时间: |
|
| 查看次数: |
118 次 |
| 最近记录: |