Symfony 3 routing subdomains - .htaccess

I have to bundles, frontend and backend. I want the subdomain "admin.domain.com" to work as "admin.domain.com/whateverpage" and controlled by the backend bundle controllers. All other subdomains should work like "sub1.domain.com/{dynamicwhateverpage}" or "sub2.domain.com/{dynamicwhateverpage}" and be controlled by the frontend bundle controllers.
I got it to work with "admin.domain.com/backend/whateverpage" and "sub1.domain.com/frontend/{dynamicwhateverpage}". The backend and frontend in the URL of course should not be visible to the users. Is there a way to rewrite with htaccess? Or is there even a better way to achieve this kind of rewriting?

Symfony can match routing based on host. This should also work when importing routes, though I have not tested it;
/**
* #Route("/", name="project_page", host="{project}.example.com")
*/
public function projectPageAction($project) {
// ...
}
Just make sure your none dynamic routes are loaded before the all capturing one, or make sure the project one can't match eg. admin.
Earlier Routes Always Win
Why would you ever care about requirements? If a request matches two routes, then the first route always wins.

Related

how to use azure front door to route traffic using wildcards in path

We want to set up domain.com so to route based on path, using wildcards like this:
for most cases, domain.com/* routes to one resource, keeping original domain
BUT
if URL is domain.com/blog/, it redirects to blog.domain.com/ at another resource. Basically, we want to take whatever comes after /blog/ in the first URL and append it to blog.domain.com in the second URL.
Is there a way to reliably do that using routes and rule sets in Front Door?
I tried setting up 2 routes within an endpoint:
domain.com/* routes to origin group that contains our sites main static web app. Origin path is blank.
domain is domain.com, patterns to match is /blog/* routes to origin group that contains custom url blog.domain.com. origin path is /*
Seems like it works sometimes, but not always. domain.com/blog does not go to blog.domain.com. Some specific paths/pages on the blog redirect properly, but others do not.
I have tried with rule sets, but haven't been able to get it to take only part of the path (everything AFTER /blog/) instead of just all or nothing.
Is there a way to reliably do that using routes and rule sets in Front Door?
Yes, we can route the specific requests that match a routing rule. I have tried to replicate the same in local; here is the routing rule engine configuration for backend pool 1 and backend pool 2.
if it was wildcard *, all traffic will be route to that particular route i.e main static web page.
Create second route configuration for blog portal.
When incoming request comes as domain.com -> its turns to first route rule and load static web app
If incoming request comes as domain.com/blog/ -> it turns to second route rule and load respective backend endpoint.
reference tutorial for more information

Azure Application Gateway - single parent domain for multiple web applications

I am trying to setup one parent domain (app.mydomain.com) for front for 2 web apps in the backend.
mail.mydomain.com and module.mydomain.com. I have implement path based routing. I need to routing to work so
app.mydomain.com/* points module1.mydomain.com
app.mydomain.com/module2/* points module2.mydomain.com/
Routing seems to work, however when browsing module2, it css and js are not loaded and the site doesnt work. accessing module2 directly works normally.
Have you routing rules to change your URL?
Since you are using App Gateway, the URL that your backend is seeing is (app.mydomain.com) instead of module2.mydomain.com.
So, maybe when you’re using the AppGateway, your backend is looking for a CSS into the wrong path…

How to configure React Routes for different domains pointing to the same application with different URLs

We have a working React app for http://domain1.com/directory/members/jim
We'd like to use the same app for http://domain2.com/jim
How can we define the routes for the two domains? Or can we put in place a substitution algorithm somewhere?
You can make both urls work for all domains, but then you can't have a member named "directory". That is a really ugly restriction.
Why don't you just serve 2 different apps on the 2 domains? They can still share 99 % of the code.

NuxtJS dynamic URLs for static site

How can I allow for dynamic URLs on a static Nuxt.js application? I have some dynamic routes like this.
/user/_user
/order-confirmation/_key
/some-route/_key/with/additional/_slug
I generate most of the routes on build time, but some IDs will exist after creating the app. I believe I could use .htaccess somehow to allow for this, but so far, I haven't been able to get it working. I have tried with this: nuxtjs cannot display dynamic url on production - but that doesn't seem to work either.
I can't believe there isn't more information on this, must be a pretty regular usecase.

Sails.js res.redirect() don't support proxyHost

I have config
proxyHost: 'http://localhost:1337/1.0',
and routes
'GET /1.0/subscriptions/success': 'SubscriptionController.success',
In controller,
res.redirect('/subscriptions/success');
Browser is redirect to URL "http://localhost:1337/subscriptions/success", I expect it will redirect to "http://localhost:1337/1.0/subscriptions/success".
Where can I make config to this?
You're misunderstanding what the proxyHost setting is for. It is solely to allow sails.getBaseurl() to return the correct base URL for when your site is being proxied (e.g. by Nginx) so that the public-facing host/port is different from the host/port exposed on the server. It doesn't affect the URLs of the routes that are bound in your app, nor does it affect the action of res.redirect.
If you want to prefix all of your routes with /1.0, you can use the prefix setting in config/blueprints (documented here). You'll still need to include the prefix manually when doing redirects, but you won't need to actually nest your controllers under a /1.0 folder.

Resources