LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 11-09-2019, 01:28 PM   #1
Märk Owen
LQ Newbie
 
Registered: Nov 2014
Posts: 22

Rep: Reputation: Disabled
NGINX - How do I redirect to an url with arguments ?


Hello,

I need to redirect the following url :
https://mywebsite.com/service/
to :
https://mywebsite.com/service/?cnx=1

I can't seem to make it work. If my url has a trailing slash, it doesn't redirect at all but if it doesn't add a url it gives me the following result :

https://mywebsite.com/service/?cnx=1...=1?cnx=1?cnx=1

etc....

I've currently setup my config so it also adds a trailing slash to the url "https://mywebsite.com/service" if it's not already done. I'd like to keep that config.

Thank you.
 
Old 11-10-2019, 03:49 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
Quote:
Originally Posted by Märk Owen View Post
Hello,

I need to redirect the following url :
https://mywebsite.com/service/
to :
https://mywebsite.com/service/?cnx=1

I can't seem to make it work. If my url has a trailing slash, it doesn't redirect at all but if it doesn't add a url it gives me the following result :

https://mywebsite.com/service/?cnx=1...=1?cnx=1?cnx=1

etc....

I've currently setup my config so it also adds a trailing slash to the url "https://mywebsite.com/service" if it's not already done. I'd like to keep that config.

Thank you.
You may try the following:
Code:
if ($query_string !~* cnx=) {
rewrite ^/service/$ $scheme://$host/service/?cnx=1? break ;
}
 
1 members found this post helpful.
Old 11-10-2019, 05:21 AM   #3
Märk Owen
LQ Newbie
 
Registered: Nov 2014
Posts: 22

Original Poster
Rep: Reputation: Disabled
It works. Thanks!
 
  


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
Nginx, Horde, Https, Redirect, This webpage has a redirect loop axetone Ubuntu 0 02-08-2015 10:44 PM
Redirect with URL not showing the new redirects URL link Apache RHEL 6 gdizzle Linux - Newbie 4 12-03-2013 03:09 AM
[Help] Rewrite URL failure in nginx - url end with #string ubungu Linux - Server 0 07-11-2013 07:44 AM
Cannot Redirect URL to another URL when the link is down with Squid marx_long Linux - Newbie 1 06-13-2010 08:59 PM
Problem with dynamic url rewrite and redirect in nginx??? gavin2u Linux - Server 3 05-27-2010 10:25 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:08 PM.

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