Question: How do I make it so that if a response has been sent back, then no more responses should be sent? **Actually, the issue is that if a response is sent back, then express (or nodejs) shouldn't continue running through the rest of the code.**

I've tried doing next() but terminal throws the error of next() being undefined. res.end() doesn't seem to work either? 

routing.js: 

```
router.post('/user/create', function(req, res, next) {
    user.createUser(req, res);
});

```

user.js createUser

```
user.prototype.createUser = function(req, res, next) {
    var body = req.body;
    checkAllInput(body, res, next);
    // do some more checks then finally create user
}

```

user.js createUser

```
function checkAllInput(body, res, next) {
    checkError.checkUsername(body, res, next);
    checkError.checkPassword(body, res, next);

```

}

checkError.js

```
userClass.prototype.checkUsername = function(username, res) {
    if (!username || username === "bob) {
        res.status(406).send("username");
    }
}

userClass.prototype.checkPassword = function(password, res) {
    if (!password || password === "hello") {
        res.status(406).send("password");
    }
}

```

Call createUser in routing, which then calls checkAllInput which calls checkUsername but should stop if username sends a response back.

Answer: 
Check the configuration file in /etc/apache2/sites-available/your\_site\_name.conf. If you have a Redirect "/" "<https://your_site_name.whatever>", it might be that the redirect is stripping the forward slash from the URL there. If this is the problem, just add a trailing forward slash to the redirect url. This is what happened to me. I could navigate to the index.php but not to the info.php file I had placed at the root when I set up the virtual host.
Scour your Apache configuration for Redirect\* or Rewrite\* rules; also all .htaccess files in the DocumentRoot. If that doesn't turn up anything, examine the PHP application you're using.