Deploying a site on subdirectory results in 404
Closed this issue · 9 comments
I've setup .htaccess correctly and set the $config['site_url'] in the config.php file
I'm still shown a 404 and it looks like it doesn't know anything of my subdirectory. Checking site_url() returns my domain without the subdirectory.
Any suggestions?
As of right now there is a problem with placing the system in a subdirectory. The problem as you noticed is that the site_url() function does not check the config value. This should be fixed in the next iteration. For now you might need to change the site_url() function in the boostrap.php file.
function site_url($uri = NULL)
{
return (strpos($uri,'://')===FALSE?DOMAIN.'/'.config('site_url'):'').$uri;
}
That does work to make site_url() return the right domain/subdomain but it's still showing 404.
the 404 config works
$config['404'] = 'example/404';
by the line you see at the top of
http://tribedata.net/whb-dir/
but it's still not showing
$config['index'] = 'example/index';
What have you altered? It's reporting the problem as being a missing "content" value which each controller is supposed to set ($this->content = ...) because it's called in the final layout.php view (print $content).
Oh, those errors aren't related. layout.php isn't getting $content because I just replaced everything in the controller with the simple echo you see at the top to make sure it understood
$config['404'] = 'example/404';
I thought I might be doing something wrong there but I'm not.
Just so we're clear, example/404
calls the Controller->show_404() which sends a 404 header and loads the 404.php view file. So you should be getting a 404 on that page. However, I manually added the sub directory to the path for the other pages (http://tribedata.net/whb-dir/example/form) and it seems to load fine. You probably need to edit the layout.php file and add that path to them also (since the I can see the CSS files aren't loading either because they are missing the subdirectory).
http://tribedata.net/theme/view/css/base.css
to
http://tribedata.net/whb-dir/theme/view/css/base.css
I understand about the 404. I had altered that stuff to show my own 404 text to make sure it was working correctly, which is was.
If you load any of the subpage or the main page now, you'll see it is actually loading 404.
The problem is the URL routing does not take the subdirectory into account when figuring out which controller to load. For example, given the URI whb-dir/example/form
index.php is actually trying to load the class new Whb-dir_Controller_Example()
and call the Form() method. I'll fix this in the next release.
I'm currently in the process of uncompressing all the code so it will be much easier to read. Checkout the "development" branch if you need to understand how something works.
Hmm, loading in the development version gives me a white screen no matter what I do.
I'm working to go line by line and see where it's failing.
I just noticed that your server is using PHP/5.2.9. MicroMVC is only built to work on PHP 5.3 and higher because of the use of late static binding and other new features. If you are running a Debian/Ubuntu server you can upgrade your PHP package using dotdeb or installing Debian 6. If you are on a shared host there is not much you can do but request PHP 5.3 to be installed.