I recently had to move a CodeIgniter based website from the web root of:
/var/www/vhosts/dev/
to:
/var/www/vhosts/dev/site1/
The problem I am encountering is that I need the web root to still remain accessible from the domain: http://www.devdomain.com
All relative links now are broken since they obviously were referring to the web root.
Is there a rewrite rule or something at the top-level I can use that will automatically add the site1/ to all relative based links?
So, what would have normally been;
<a href="/enrollment">Enrollment</a>
https://www.devdomain.com/enrollment
Now needs to become;
<a href="/enrollment">Enrollment</a>
https://www.devdomain.com/site1/enrollment
Any help would be extremely appreciated.
The $config[‘base_url’] fix Nikola mentions would work if you used, in your links, the
Since apparently you don’t want to go through the code the problem isn’t in Codeigniter but in the server (?). Maybe a RewriteRule in the .htaccess file can help you (if you’re on Apache).
I can’t comment other answers since my rep level is low, otherwise I would’ve simply commented on Nikola’s answer.
EDIT: I just figured this out. You have to remove the initial “/” from the href attributes! It is going to the root of the webserver, it is being a relative link but not the way you think. If you remove the “/” the link will go to a file on the same directory level of your file (in this case the Codeigniter installation). Sorry but you’ll have to go through your whole code.
Additionally I would recommend for you to use site_url() to link between controllers inside Codeigniter, helps with this kind of situations and a lot others.
SECOND EDIT: It’s not site_url() but base_url(), sorry for the confusion. Just corrected the code.