Turns out the rewrite option above works as expected, I was editing the wrong file. :/
Redirect some urls from nginx to subdomain on apache server...
I have been following along with the TDD Forum series as I have an old vbulletin forum I own that I have wanted to update for a long time. I was pretty pumped when I saw the first video posted as it was exactly what I was looking for. After a few months of development, I'm now at the point where my new forum is ready to launch.
The issue is, I'm not pulling over the 8 years of history but still want it archived as I get a little bit of ad money from it each month. The plan is to point my current domain to a new server with my awesome new laravel forum (nginx on Digital Ocean) and point the crummy old site (apache server on Digital Ocean) to a new subdomain (archive.domain.com).
My server admin chops aren't the greatest, so I am not sure the best way to go about this. I have essentially zero experience with nginx but based on my reading it seems like a reverse proxy might be what I need.
The old site url structure is as follows:
www.domain.com/forum/forum.php
www.domain.com/forum/forumdisplay.php?1-Forum-name
www.domain.com/forum/showthread.php?1234-Thread-title
www.domain.com/forum/member.php?1-Username
There are other sections to the site, but these are the important pages that I want to make sure have the proper redirect in place.
The new url structure is:
www.domain.com/forum/forum-slug/thread-slug
www.domain.com/profile/username
My question is, will it be possible to redirect any requests for the old urls to a new subdomain (archive.domain.com/forum/*)? If so, is a reverse proxy the right approach? My thinking is that I would check to see if the request has the url structure of the old site and redirect to the apache server, otherwise it lets them through to the newly built laravel site.
If I am on the right track, I've yet to wrap my head around how to structure my nginx config to accomplish this. It seems like I should be able to create a different location block for each url of the old structure I'd like to redirect to but my attempts at testing are coming up short.
location ~ /test/(.*) {
rewrite ^ http://archive.domain.com/test/;
}
I also found documentation on the following option.
rewrite ^/test/(.*) http://archive.domain.com/test/ permanent;
The above attempts did not work as I expected, I got a 404 error for each.
I've found a lot of documentation that would be helpful if I needed to redirect ALL traffic to a subdomain, but I'm not finding anything helpful for redirecting specific urls to a subdomain. Any help or guidance would be greatly appreciated.
Please or to participate in this conversation.