Answer the question
In order to leave comments, you need to log in
Is it good practice to use CodeIgniter's base_url() in Views?
The bottom line is that a web application based on the CodeIgniter PHP framework first lay in the root of the site, but then was asked to remove it to the subfolder subfolder . That is, the application was in /www , and they asked to move it to /www/subfolder .
In the config.php config, I changed the base_url parameter:
$config['base_url'] = 'http://domain.com/subfolder/';
<link href="/css/main.css" rel="stylesheet">
<link href="<?= base_url('css/main.css') ?>" rel="stylesheet">
<form id="user-login" action="/login" method="post">
...
</form>
<form id="user-login" action="<?= base_url('login') ?>" method="post">
...
</form>
Answer the question
In order to leave comments, you need to log in
Is such a replacement in all Views considered an acceptable (correct) practice? Do they do it at all?
Yes. But it's painful.
Remove the slash from href="/* and src="/* - so that the web server looks for files in the current directory.
Does the editor have an autocorrect feature for all files in a subdirectory?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question