Membership is FREE, giving all registered users unlimited access to every Acorn Domains feature, resource, and tool! Optional membership upgrades unlock exclusive benefits like profile signatures with links, banner placements, appearances in the weekly newsletter, and much more - customized to your membership level!

Nginx Redirect Help

Status
Not open for further replies.
Joined
Feb 11, 2010
Posts
3,036
Reaction score
110
Anyone here know about redirecting on a nginx server

what I'm trying to do is redirect some old asp pages to a flat html page on a site I'm reviving for juice.

I've tried adding
Code:
# nginx configuration
location /index.asp?ID=38 {
rewrite ^(.*)$ [URL]http://www.newsite.org.uk/cumbria.htm[/URL] redirect;
}
location /index.asp?ID=39 {
rewrite ^(.*)$ [URL]http://www.newsite.org.uk/greater-manchester.htm[/URL] redirect;
}

to the config file but now joy I think its something to do with the ? not being escaped properly but I'm dammed if I know how to fix it.

I used to think .htaccess was confusing but trying to find stuff on this is a pain in the backside
 
You need to escape the question marks and the rewrites should probably be in your "location /" block, like so:

Code:
location / {
  rewrite index.asp\?ID=38 http://www.newsite.org.uk/cumbria.htm redirect;
  rewrite index.asp\?ID=39 http://www.newsite.org.uk/greater-manchester.htm redirect;
}

Also it's worth noting that the 'redirect' flag is a temporary redirect (302) - if you want a permanent redirect (301) use the 'permanent' flag instead.
 
Thanks it didn't quite work how I needed it

but I've figured out htaccess can actually work with the vps I'm on so sorted it now anyway
Thanks again for having a look
 
Status
Not open for further replies.

The Rule #1

Do not insult any other member. Be polite and do business. Thank you!

Members online

Premium Members

New Threads

Domain Forum Friends

Our Mods' Businesses

*the exceptional businesses of our esteemed moderators
General chit-chat
Help Users
  • No one is chatting at the moment.
      There are no messages in the current room.
      Top Bottom