Membership is FREE – with unlimited access to all features, tools, and discussions. Premium accounts get benefits like banner ads and newsletter exposure. ✅ Signature links are now free for all. 🚫 No AI-generated (LLM) posts allowed. Share your own thoughts and experience — accounts may be terminated for violations.

Nginx Redirect Help

Status
Not open for further replies.
Joined
Feb 11, 2010
Posts
3,038
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.

Rule #1: Be Respectful

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

Members online

No members online now.

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.
  • Siusaidh AcornBot:
    Siusaidh has left the room.
      Siusaidh AcornBot: Siusaidh has left the room.
      Top Bottom