You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Codeigniter网站部署至000webhost服务器后出现404页面未找到问题

Fixing 404 Error for Your VegShop on 000webhost

Hey there, let's work through this 404 issue you're facing with your vegshop folder on 000webhost. I've dealt with similar host-specific rewrite rule quirks before, so here's what to check and fix:

First, Verify the Basics

  • Double-check your file structure: Make sure your index.php is directly inside the vegshop folder (not nested deeper). The DirectoryIndex index.php rule tells the server to look for this file first, so if it's missing or in the wrong spot, you'll get a 404.
  • Test direct access: Try visiting http://sp16bcs034.000webhostapp.com/vegshop/index.php directly. If this loads fine, the problem is definitely with your .htaccess rewrite rules. If it still 404s, you've got a file placement or permission issue—ensure files have 644 permissions and folders have 755.

Fix the .htaccess Rewrite Rules

The main issue here is likely that your rewrite rules aren't accounting for the vegshop subdirectory. 000webhost's server needs explicit guidance on where your index file lives relative to the root. Update your .htaccess (make sure it's placed inside the vegshop folder, not the server root) to this:

Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
RewriteEngine on
RewriteBase /vegshop/
RewriteCond $1 !^(index\.php|resources|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]

What Changed?

  • Added RewriteBase /vegshop/: This tells the rewrite engine that all rules are relative to the vegshop subdirectory, so it doesn't try to look for index.php in the server's root folder.
  • Kept your existing exclusion rules intact—those are good for skipping real files/folders like CSS, JS, and images.

Final Checks

  • Clear your browser cache (or use incognito mode) after updating .htaccess—sometimes old cached responses can still show 404s.
  • If you're using a framework (like CodeIgniter, which this .htaccess looks familiar from), make sure the framework's base URL is set to http://sp16bcs034.000webhostapp.com/vegshop/ in its config file. That's often a missing piece with subdirectory deployments.

内容的提问来源于stack exchange,提问作者Fahad Mahmood

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 10:05:44