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.phpis directly inside thevegshopfolder (not nested deeper). TheDirectoryIndex index.phprule 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.phpdirectly. If this loads fine, the problem is definitely with your.htaccessrewrite rules. If it still 404s, you've got a file placement or permission issue—ensure files have644permissions and folders have755.
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 thevegshopsubdirectory, so it doesn't try to look forindex.phpin 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
.htaccesslooks familiar from), make sure the framework's base URL is set tohttp://sp16bcs034.000webhostapp.com/vegshop/in its config file. That's often a missing piece with subdirectory deployments.
内容的提问来源于stack exchange,提问作者Fahad Mahmood
相关产品推荐
相关产品推荐

