admin管理员组文章数量:1410705
example url reactjs appp route: /%7Brandomstring%7D
randomstring is actually an id that i use.
Question: How can i use nginx to point to this route.
reactjs build files are under
/var/www/html/
I tried following nginx config:
location \~\* (.\*/home/)(.+)$
{
return 301 ( ; #not really what i want
}
No success with the following too
location \~\* (.\*/home/)(.+)$
{
alias /var/www/html/;
index index.html index.js;
try_files $uri $uri/ /index.html?$args;
}
Following worked:
location /home/ {
alias /var/www/html/;
index index.html index.js;
try_files $uri $uri/ /index.html?$args;
}
example url reactjs appp route: https://domain.de/home/%7Brandomstring%7D
https://domain.de/home/123uwb2j3u2
https://domain.de/home/128283283s
randomstring is actually an id that i use.
Question: How can i use nginx to point to this https://domain.de/home/128283283s route.
reactjs build files are under
/var/www/html/
I tried following nginx config:
location \~\* (.\*/home/)(.+)$
{
return 301 https://domain.de/anotherRoute( ; #not really what i want
}
No success with the following too
location \~\* (.\*/home/)(.+)$
{
alias /var/www/html/;
index index.html index.js;
try_files $uri $uri/ /index.html?$args;
}
Following worked:
location /home/ {
alias /var/www/html/;
index index.html index.js;
try_files $uri $uri/ /index.html?$args;
}
Share
edited Mar 5 at 4:33
Faisal Mahmood
asked Mar 4 at 12:13
Faisal MahmoodFaisal Mahmood
133 bronze badges
2
|
1 Answer
Reset to default 1if you are not using nginx as a proxy then, the below should work.
server {
listen 80;
server_name domain.de;
root /var/www/html;
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
# specifically for /home/{id} routes
location ~ ^/home/ {
try_files $uri $uri/ /index.html;
}
}
本文标签: reactrouterdome nginx routing problem for dynamic string at the end of URLStack Overflow
版权声明:本文标题:react-router-dome nginx routing problem for dynamic string at the end of URL - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745043849a2639240.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
index.html
file? Is it/var/www/html/index.html
or/var/www/html/home/index.html
(or neither first nor second)? – Ivan Shatsky Commented Mar 4 at 13:22