So I've got this weird problem, I am trying to host a php codeigniter project but I can only access my index page all the other pages give me a 404 error

I want it on port 81 so in ports.conf I have added Listen 81 (No problems there but I'm going to give all the configs I have changed so you have some sort of overview)


Alias "/foo" "/var/www/foo
<Directory /var/www/foo>
    Options Indexes FollowSymLinks ExecCGI
    AllowOverride All
    AddHandler cgi-script .php
    Require all granted


<VirtualHost *:81>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/foo
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

So the problem now is I can go to which shows me my index but when I try to go to it gives me a 404 but does give me the page I'm looking for...

I'm a bit puzzled as to what is going on, also not sure anymore what to google or how to find the answer I'm looking for.

I'm thinking it might have something to do with the rewrite module, no clue what though.

This is my htacces file in the foo directory

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]

Also when I run it locally on my machine with AMPPS I don't have any of there troubles.

I think I fixed it. I think it was an error in my code igniter project in the file application/config/config.php I had my $config['base_url'] pointing to the wroung url.

  • I see that you have DocumentRoot set to /var/www/team28 in your foo.conf file. If "team28" is the "foo" you are looking for, then you would need to set your DocumentRoot to /var/www. Otherwise, is there a folder "foo" under team28 folder? – Olivier Mar 12 '19 at 17:14
  • Yes that's the foo, I changed in my post. In /var/www I also have some other folders which I don't want to open on port 81 but rather on port 80. Port 80 is for stuff in my lan but I would like 81 to be accessible outside of the lan. – stilllearning Mar 13 '19 at 16:14
  • I'm voting to close this question as off-topic because you indicate you solved the problem without getting any answers. – Stephen Ostermiller Mar 14 '19 at 10:40