How to do nginx redirect for dynamic page urls The Next CEO of Stack OverflowIn Nginx, how can I rewrite all http requests to https while maintaining sub-domain?nginx ssl redirectnginx redirect dynamic page urlsNginx Redirect via Proxy, Rewrite and Preserve URLNginx redirect loop with Wordpressnginx redirect several https subdomains to different urlsnginx: ssl verification failed + wrong redirectExclude Let's Encrypt http requests from nginx https redirectNGINX redirect for multiple domainsNginx http to https redirect not working when listening to upstream loadbalancer
Is it my responsibility to learn a new technology in my own time my employer wants to implement?
How easy is it to start Magic from scratch?
When did Lisp start using symbols for arithmetic?
How do I solve this limit?
Apart from "berlinern", do any other German dialects have a corresponding verb?
Opposite of a diet
Inappropriate reference requests from Journal reviewers
Implement the Thanos sorting algorithm
Fastest way to shutdown Ubuntu Mate 18.10
Science fiction (dystopian) short story set after WWIII
Error when running sfdx update to 7.1.3 then sfdx push errors
What makes a siege story/plot interesting?
Why do professional authors make "consistency" mistakes? And how to avoid them?
Why here is plural "We went to the movies last night."
What is meant by a M next to a roman numeral?
Can a single photon have an energy density?
Whats the best way to handle refactoring a big file?
Is the concept of a "numerable" fiber bundle really useful or an empty generalization?
Rotate a column
Natural language into sentence logic
What happens if you roll doubles 3 times then land on "Go to jail?"
How do scammers retract money, while you can’t?
Does it take more energy to get to Venus or to Mars?
How do we know the LHC results are robust?
How to do nginx redirect for dynamic page urls
The Next CEO of Stack OverflowIn Nginx, how can I rewrite all http requests to https while maintaining sub-domain?nginx ssl redirectnginx redirect dynamic page urlsNginx Redirect via Proxy, Rewrite and Preserve URLNginx redirect loop with Wordpressnginx redirect several https subdomains to different urlsnginx: ssl verification failed + wrong redirectExclude Let's Encrypt http requests from nginx https redirectNGINX redirect for multiple domainsNginx http to https redirect not working when listening to upstream loadbalancer
I need to change nginx config in a way , that every dynamically generated request is being redirected to main domain.
I'm not sure how to achieve this. Help please!
Not sure if this matters, but I want to add, that traffic goes thru nginx reveser proxy (ssl) to simple web server (nginx)
https://mypage.com/something ->https://mypage.com
https://mypage.com/anything123 ->https://mypage.com
https://mypage.com/randomtext ->https://mypage.com
nginx redirect
New contributor
add a comment |
I need to change nginx config in a way , that every dynamically generated request is being redirected to main domain.
I'm not sure how to achieve this. Help please!
Not sure if this matters, but I want to add, that traffic goes thru nginx reveser proxy (ssl) to simple web server (nginx)
https://mypage.com/something ->https://mypage.com
https://mypage.com/anything123 ->https://mypage.com
https://mypage.com/randomtext ->https://mypage.com
nginx redirect
New contributor
1
How can you tell which request needs to be redirected?
– Michael Hampton♦
Mar 25 at 13:49
add a comment |
I need to change nginx config in a way , that every dynamically generated request is being redirected to main domain.
I'm not sure how to achieve this. Help please!
Not sure if this matters, but I want to add, that traffic goes thru nginx reveser proxy (ssl) to simple web server (nginx)
https://mypage.com/something ->https://mypage.com
https://mypage.com/anything123 ->https://mypage.com
https://mypage.com/randomtext ->https://mypage.com
nginx redirect
New contributor
I need to change nginx config in a way , that every dynamically generated request is being redirected to main domain.
I'm not sure how to achieve this. Help please!
Not sure if this matters, but I want to add, that traffic goes thru nginx reveser proxy (ssl) to simple web server (nginx)
https://mypage.com/something ->https://mypage.com
https://mypage.com/anything123 ->https://mypage.com
https://mypage.com/randomtext ->https://mypage.com
nginx redirect
nginx redirect
New contributor
New contributor
New contributor
asked Mar 25 at 12:49
GregGreg
1
1
New contributor
New contributor
1
How can you tell which request needs to be redirected?
– Michael Hampton♦
Mar 25 at 13:49
add a comment |
1
How can you tell which request needs to be redirected?
– Michael Hampton♦
Mar 25 at 13:49
1
1
How can you tell which request needs to be redirected?
– Michael Hampton♦
Mar 25 at 13:49
How can you tell which request needs to be redirected?
– Michael Hampton♦
Mar 25 at 13:49
add a comment |
2 Answers
2
active
oldest
votes
You could have two location blocks, one for exact match of root directory and the other one for everything else.
location = /
try_files /index.html = 404;
location /
return 301 /;
rewrite
also can be used instead of return
(redirect), but will be slower.
location /
rewrite ^ / permanent;
Another option is just to have a rewrite
for everything (inside server block), without any location blocks. In this method, url will remain as the original url you typed on the browser.
server
root /xxx/xxx/xx;
server_name mypage.com;
rewrite ^.*$ /index.html;
add a comment |
You to force all pages to the main domain?
this is the php, you can also embed into another page
<?php
$url=$_SERVER['HTTP_HOST'];
if($url!=$_SERVER['SERVER_NAME'])
header("Location:https://url.host");
?>
1
This is completely irrelevant. There is no PHP mentioned in the question, and this isn't a site about programming anyway.
– Michael Hampton♦
Mar 25 at 13:49
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "2"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Greg is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f959846%2fhow-to-do-nginx-redirect-for-dynamic-page-urls%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You could have two location blocks, one for exact match of root directory and the other one for everything else.
location = /
try_files /index.html = 404;
location /
return 301 /;
rewrite
also can be used instead of return
(redirect), but will be slower.
location /
rewrite ^ / permanent;
Another option is just to have a rewrite
for everything (inside server block), without any location blocks. In this method, url will remain as the original url you typed on the browser.
server
root /xxx/xxx/xx;
server_name mypage.com;
rewrite ^.*$ /index.html;
add a comment |
You could have two location blocks, one for exact match of root directory and the other one for everything else.
location = /
try_files /index.html = 404;
location /
return 301 /;
rewrite
also can be used instead of return
(redirect), but will be slower.
location /
rewrite ^ / permanent;
Another option is just to have a rewrite
for everything (inside server block), without any location blocks. In this method, url will remain as the original url you typed on the browser.
server
root /xxx/xxx/xx;
server_name mypage.com;
rewrite ^.*$ /index.html;
add a comment |
You could have two location blocks, one for exact match of root directory and the other one for everything else.
location = /
try_files /index.html = 404;
location /
return 301 /;
rewrite
also can be used instead of return
(redirect), but will be slower.
location /
rewrite ^ / permanent;
Another option is just to have a rewrite
for everything (inside server block), without any location blocks. In this method, url will remain as the original url you typed on the browser.
server
root /xxx/xxx/xx;
server_name mypage.com;
rewrite ^.*$ /index.html;
You could have two location blocks, one for exact match of root directory and the other one for everything else.
location = /
try_files /index.html = 404;
location /
return 301 /;
rewrite
also can be used instead of return
(redirect), but will be slower.
location /
rewrite ^ / permanent;
Another option is just to have a rewrite
for everything (inside server block), without any location blocks. In this method, url will remain as the original url you typed on the browser.
server
root /xxx/xxx/xx;
server_name mypage.com;
rewrite ^.*$ /index.html;
answered 18 hours ago
ChamindaChaminda
312
312
add a comment |
add a comment |
You to force all pages to the main domain?
this is the php, you can also embed into another page
<?php
$url=$_SERVER['HTTP_HOST'];
if($url!=$_SERVER['SERVER_NAME'])
header("Location:https://url.host");
?>
1
This is completely irrelevant. There is no PHP mentioned in the question, and this isn't a site about programming anyway.
– Michael Hampton♦
Mar 25 at 13:49
add a comment |
You to force all pages to the main domain?
this is the php, you can also embed into another page
<?php
$url=$_SERVER['HTTP_HOST'];
if($url!=$_SERVER['SERVER_NAME'])
header("Location:https://url.host");
?>
1
This is completely irrelevant. There is no PHP mentioned in the question, and this isn't a site about programming anyway.
– Michael Hampton♦
Mar 25 at 13:49
add a comment |
You to force all pages to the main domain?
this is the php, you can also embed into another page
<?php
$url=$_SERVER['HTTP_HOST'];
if($url!=$_SERVER['SERVER_NAME'])
header("Location:https://url.host");
?>
You to force all pages to the main domain?
this is the php, you can also embed into another page
<?php
$url=$_SERVER['HTTP_HOST'];
if($url!=$_SERVER['SERVER_NAME'])
header("Location:https://url.host");
?>
answered Mar 25 at 13:28
freddybobjofreddybobjo
15
15
1
This is completely irrelevant. There is no PHP mentioned in the question, and this isn't a site about programming anyway.
– Michael Hampton♦
Mar 25 at 13:49
add a comment |
1
This is completely irrelevant. There is no PHP mentioned in the question, and this isn't a site about programming anyway.
– Michael Hampton♦
Mar 25 at 13:49
1
1
This is completely irrelevant. There is no PHP mentioned in the question, and this isn't a site about programming anyway.
– Michael Hampton♦
Mar 25 at 13:49
This is completely irrelevant. There is no PHP mentioned in the question, and this isn't a site about programming anyway.
– Michael Hampton♦
Mar 25 at 13:49
add a comment |
Greg is a new contributor. Be nice, and check out our Code of Conduct.
Greg is a new contributor. Be nice, and check out our Code of Conduct.
Greg is a new contributor. Be nice, and check out our Code of Conduct.
Greg is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Server Fault!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f959846%2fhow-to-do-nginx-redirect-for-dynamic-page-urls%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
How can you tell which request needs to be redirected?
– Michael Hampton♦
Mar 25 at 13:49