I’m very new to Apache and CodeIgniter. Trying to route
<VirtualHost *:80> ServerName localhost ServerPath /codeigniter DocumentRoot /var/www/CodeIgniter <Directory /var/www/CodeIgniter> Allowoverride All </Directory> </VirtualHost>
$config['base_url'] = 'http://localhost/codeigniter';
http://localhost/codeigniter gives me codeigniter, but
http://localhost/ also gives it to me when I expect
What should I change?
Nowhere do you configure your DocumentRoot in the snippet you give – thus we have no clue that you might be serving anything from
I’d expect a directive
DocumentRoot /var/www/html somewhere within your VirtualHost (I prefer such a directive in the VirtualHost, not in the global server configuration). From there on, let’s look at the Apache httpd documentation:
There are frequently circumstances where it is necessary to allow web
access to parts of the filesystem that are not strictly underneath the
DocumentRoot. httpd offers several different ways to accomplish this.
On Unix systems, symbolic links can bring other parts of the
filesystem under the
DocumentRoot. For security reasons, httpd will
follow symbolic links only if the
Optionssetting for the relevant
Aliasdirective will map any part of the filesystem
into the web space. For example, with
Alias "/docs" "/var/web"
http://www.example.com/docs/dir/file.htmlwill be served from
i.e. I’d expect an Alias, to do the job.
Alias "/codeigniter" "/var/www/CodeIgniter"
All in all, closer to (this is not complete/tested):
<VirtualHost *:80> ServerName localhost DocumentRoot /var/www/html Alias "/codeigniter" "/var/www/CodeIgniter" </VirtualHost>
Directory, other directives and permissions etc. to taste)