Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

211
Views
Apache configure ServerPath for CodeIgniter

I'm very new to Apache and CodeIgniter. Trying to route /var/www/html to http://localhost/ and /var/www/CodeIgniter to http://localhost/codeigniter

Apache conf:

<VirtualHost *:80>
    ServerName localhost
    ServerPath /codeigniter
    DocumentRoot /var/www/CodeIgniter
    <Directory /var/www/CodeIgniter>
          Allowoverride All
    </Directory>
</VirtualHost>

CodeIgniter:

$config['base_url'] = 'http://localhost/codeigniter';

http://localhost/codeigniter gives me codeigniter, but http://localhost/ also gives it to me when I expect /var/www/html

What should I change?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Nowhere do you configure your DocumentRoot in the snippet you give - thus we have no clue that you might be serving anything from /var/www/html.

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 Options setting for the relevant directory includes FollowSymLinks or SymLinksIfOwnerMatch.

Alternatively, the Alias directive will map any part of the filesystem into the web space. For example, with

Alias "/docs" "/var/web"

the URL http://www.example.com/docs/dir/file.html will be served from /var/web/dir/file.html.

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>

(add Options, Directory, other directives and permissions etc. to taste)

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!