I’m doing a website, and now I hosted it in a free host service just to do some tests.
And I’m having a problem that I don’t have in localhost.
The problem is: I can access my homepage successfully, but whenever I try to access a secondary page I get a 404 error "http://error404.000webhost.com/? ".
I don’t see why I’m getting this error, in localhost everything works perfectly, so I will put below my code that I think that can be related to this issue.
Any help will be very welcome.
My Home() function that I call in my index.php file with my query string:
function Home(){
$url = $_GET['url'];
$url = explode('/', $url);
$url[0] = ($url[0] == NULL ? 'index' : $url[0]);
if(file_exists('inc/'.$url[0].'.php')){
require_once('inc/'.$url[0].'.php');
}
elseif(file_exists($url[0].'/'.$url[1].'/'.$url[2].'.php')){
require_once($url[0].'/'.$url[1].'/'.$url[2].'.php');
}
elseif(file_exists($url[0].'/'.$url[1].'.php')){
require_once($url[0].'/'.$url[1].'.php');
}
else{
require_once('inc/404.php');
}
}
My htaccess file:
RewriteBase / (we need to use this in 1st htaccess line in the host Im testing)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url=$1
How I acess my secundary pages: (In this case my teachers/documents secundary page)
<li class="item_menu">
<a href="javascript:void(0);">Teachers</span></a>
<ul>
<li>
<a href="<?php echo BASE;?>/teachers/documents"> Documents</a>
</li>
</ul>
</li>
My BASE variable:
In localhost:
define('BASE', 'htp://localhost/website');
When I host my project in a host service:
define('BASE','http://myhostexample.org');