Enjoy unlimited access to all forum features for FREE! Optional upgrade available for extra perks.

Nginx Redirect Help

Status
Not open for further replies.
Joined
Feb 11, 2010
Posts
3,062
Reaction score
113
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!

Featured Services

Sedo - it.com Premiums

IT.com

Premium Members

AucDom
UKBackorder
Be a Squirrel
Acorn Domains Merch
MariaBuy Marketplace

New Threads

Domain Forum Friends

Other domain-related communities we can recommend.

Our Mods' Businesses

Perfect
Service
Laskos
*the exceptional businesses of our esteemed moderators
Top Bottom