无法在000webhost.com中打开控制器(PHP网页);error404.000webhost.com/”;


Unable to open a controller(PHP web page) in 000webhost.com. "error404.000webhost.com/"

我刚刚将我的测试网站的所有文件上传到000webhost.com域。我的站点是farazphptest.comxa.com

在上传网站之前,我正在开发Codeigniter。我的所有控制器在本地主机上都能正常工作,但在服务器上上传网站后,当我试图访问一个控制器(如farazphptest.comxa.com/welcome,其中"欢迎"是我的网页/控制器)时,它不起作用,并打开"error404.000webhost.com/?"我的所有控制器(包括"欢迎")在本地主机中都能正常运行,但在域上上传网站之后,只有主页才能完美加载。这是我第一次把网站放在网上,如果我错过了一些技巧,一定要告诉我。我只是简单地在网上复制了我的文件,如前所述。感谢

这是我的.htaccess文件,用于本地主机和服务器。

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /faraztest
RewriteCond $1 !^(index'.php|public|'.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /faraztest/index.php
</IfModule>

另一种解决方案是在000webhost.com上创建具有项目名称的子域,并从子域url直接调用项目,它将是这样的:

  1. 从Cpanel到子域
  2. 使用项目文件夹名称创建新子域。例如:test.farazphptest.comxa.com
  3. 用您的项目文件夹覆盖创建的子域文件夹。例如:test
  4. 在上传的项目主文件夹中编辑.htaccess,如下所示:
RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index'.php|public|'.txt)    
RewriteRule ^(.*)$ index.php/$1 [L]
  1. 现在,您可以直接从新的子域url调用您的项目

例如:http://test.farazphptest.comxa.com

以下解决了我的问题

我的.htaccess文件是

# index file can be index.php, home.php, default.php etc.
DirectoryIndex index.php
# Rewrite engine
RewriteEngine On
# condition with escaping special chars
RewriteCond $1 !^(index'.php|robots'.txt|favicon'.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]

它就像魅力一样发挥作用!