LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 04-11-2016, 12:40 PM   #1
Nolph
LQ Newbie
 
Registered: Apr 2016
Posts: 2

Rep: Reputation: Disabled
Nginx Rewrite rule for subdomains


Hello,

I have a web application that has had a name change. Im trying to figure out how to create a rewrite rule that forwards the users to the new domain for their account.

Example.

customer1.cloud.company.com -> customer1.company.cloud

We have many customers with their own domains setup. Below is what i've tried as a rewrite rule that doesn't seem to work.

Code:
  server_name ~^(\w+)\.cloud.company\.com$;
  return 301 $scheme://$1.company.cloud$request_uri;
When i try to visit the site i get redirected to ".company.cloud" seems as though the sub domain is being stripped out.

Thanks!
 
Old 04-14-2016, 08:34 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,165
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Hi,

You may try this:
Code:
  server_name ~^(.+)cloud.company\.com$;
  return 301 $scheme://$1company.cloud$request_uri;
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Nginx 301 rewrite rule Ranjith KR Linux - Newbie 2 03-25-2013 08:32 AM
Nginx rewrite rule for url like www.domain.com/something.php?asd=327154723448 Ranjith KR Linux - Server 2 03-10-2013 09:38 PM
nginx rewrite mad_penguin Linux - Newbie 0 02-25-2012 12:53 AM
nginx rewrite / redirect LMW Linux - Server 4 05-14-2011 11:37 AM
Subdomains with Apache 2.2.3 - vhost or rewrite rule? Serapis Linux - Server 8 01-25-2008 04:28 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 12:40 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration