logo
down
shadow

How Can I Use vhost to Redirect a Sub-Domain to an ExpressJS Route?


How Can I Use vhost to Redirect a Sub-Domain to an ExpressJS Route?

By : Cristina
Date : November 17 2020, 11:58 AM
Hope that helps Instead of passing a subapplication as a second argument, pass it a function that will transform the url.
code :
var express = require('express');
var vhost = require('vhost');
var app = express();

app.use(vhost('*.domain.com', function(req, res, next) {
    req.url = req.url + req.vhost[0];
    next();
}));

(...)

app.get('/business', function(req, res) {
    res.send('request to business.domain.com received!');
});


Share : facebook icon twitter icon
vhost setup to redirect multiple domains names and www version to single non-www domain

vhost setup to redirect multiple domains names and www version to single non-www domain


By : Nikhil Garg
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , As is, your vhost will accept your aliases and respond with the correct files but won't redirect the requests. If you want a canonical sub domain, you may want to add a few rewrite rules:
code :
<VirtualHost *:80>
    ServerName  domain.net
    ServerAlias www.domain.net domain.com www.domain.com

    RewriteEngine On
    RewriteCond %{HTTP_HOST}    !^domain\.net [NC]
    RewriteCond %{HTTP_HOST}    !^$
    RewriteRule ^/(.*)  http://domain.net/$1 [L,R=301]

    (the rest of the settings here)
</VirtualHost>
Laravel Redirect::route() going to wrong url on vhost

Laravel Redirect::route() going to wrong url on vhost


By : z.next
Date : March 29 2020, 07:55 AM
This might help you Problem appears to be related to having an underscore in the URL, which does not pass FILTER_VALID_URL:
https://github.com/laravel/framework/issues/2511
Dokku domains:add <app> <domain> returns unsupported vhost config found. disabling vhost support

Dokku domains:add <app> <domain> returns unsupported vhost config found. disabling vhost support


By : shwetali
Date : March 29 2020, 07:55 AM
I hope this helps you . If you didn't fill in the HOSTNAME option on initial setup of dokku you'll run into your current problem. The VHOST file has yet to be created causing the current error.
To remedy this we have to create the missing VHOST file and populate with your domain name. First SSH into your droplet and run the following (Depending on your permissions you may require sudo to create and edit the VHOST file)
code :
cd /home/dokku
touch VHOST
chmod 0755 VHOST
# Use your editor of choice nano, vim etc. 
# to add your hostname to VHOST file, eg. mydomain.com
=====> myapp Domain Names
myapp.mydomain.com
Redirect to a new domain using apache vhost configuration

Redirect to a new domain using apache vhost configuration


By : Tuans
Date : March 29 2020, 07:55 AM
this will help I have an apache vhost configurations as below. I want all my requests from , You can use (instead of RewriteRule ??):
code :
RewriteCond %{QUERY_STRING} (?:^|&)product=([^&]+) [NC]
RewriteRule ^/?loadproduct$ http://someotherdomain.com/%1? [R=301,L,NC]
Selectively redirect to a new domain using apache vhost configuration

Selectively redirect to a new domain using apache vhost configuration


By : nikita.tnv
Date : March 29 2020, 07:55 AM
To fix the issue you can do Since you have a small number of models, you could just list them out, like so:
code :
RewriteEngine On
RewriteCond %{QUERY_STRING} (?:^|&)product=(Dell-Inspiron-15) [NC,OR]
RewriteCond %{QUERY_STRING} (?:^|&)product=(Dell-Inspiron-16) [NC,OR]
RewriteCond %{QUERY_STRING} (?:^|&)product=(Dell-Inspiron-17) [NC]
RewriteRule ^/?loadproduct$ http://someotherdomain.com/%1? [R=301,L,NC]
Related Posts Related Posts :
  • Heroku deployment confusion: Vue.js frontend with Flask backend
  • NodeJs: How to handle a very high amount of timers?
  • Parallel exceution in nodejs
  • In nodejs how to send cookies in a request to a server
  • MongooseJS modify document during pre hook
  • What is the `pipe` method in NodeJS?
  • Warning: PhantomJS not found
  • how we will know on the server side if the peer still connected using Nodejs WebRTC
  • Docker Remote API & Binds
  • Serving multiple node apps with nginx on same domain
  • Waiting for user to enter input in Node.js
  • How to get instant changes in background from private api in mobile app?
  • Grunt.js: Fire livereload as soon a files are modified, before task completes
  • How to remove port number from appear in the url for node js application?
  • How to ignore libraries in browserify programmatic api
  • Node/Express/Jade style guides?
  • how do I return data from a node.js request call? (undefined is not a function)
  • res.sendfile() doesn't serve javascripts well
  • File path completion relative to the current file directory
  • Tuning node-mongodb-native connection pool size
  • Express Socket.io example server not working
  • node js can't install right on my Ubuntu computer
  • How can i do an "or" query in a Model.find on Sails?
  • Confused in starting a project in node.js with npm install
  • unit testing express route with async callback
  • Mongoose sum operation in collection
  • document save function not working in mongoose
  • Why is the zlib inflate function is not working in correct order in node.js?
  • Nested if inside each (Handlebars template in Express app)
  • How does the cookie-session middleware work in expressjs?
  • grunt-processhtml remove not working when specifying a target
  • Error: CERT_HAS_EXPIRED in Node.js request module (macu vs facebook)
  • Async web requests are making 'socket hangup' in node.js
  • ExpressJS: Middleware control flow for Router.param() & Router.use()
  • Glob recursive/zero or more directories, excluding directories
  • node.js v0.11.14 as service with --harmony
  • Running npm install from Sublime Text 2 doesn't work
  • update on a subdoc with mongoose
  • NodeJS Aerospike UDF execute memory leak
  • Alternative to path module that always uses forward-slashes?
  • How do you stream a csv file into a node web app?
  • How to modularize routing with Node.js Express
  • NodeJS - Modularising SQLite3
  • MongoDB / Node: Incorrect Arguments
  • How to use Aggregate in mongoose
  • How to generate multiple reports with mocha?
  • AWS Lambda making video thumbnails
  • MEAN stack on Ubuntu 14.04 suddenly stopped working
  • node.js/express/mongoose noob issue
  • Nodejs ssh convert output byte stream to a sliceable string
  • different behavior of process.argv
  • How to expose the Application model's register method
  • How to install FFMPEG on Node/Meteor server?
  • Gmail API not respecting UTF encoding in subject
  • installing Node modules on Docker: why are they disappearing?
  • How do I set up Node/Express to act as a STUN server?
  • What is the Linear Execution Model in Meteor?
  • connect-redis and express-session results in req.session undefined
  • Application Error Heroku - Problems with Deployment
  • How to pass node v8 args and script args to pm2?
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org