html表单路径:如何修复相对起点?

html表单路径:如何修复相对起点?

问题描述:

This seems to have different behavior depending on browsers which drives crazy.

On my server, I have nginx forward to an apache docker container.

location /foo {
        proxy_pass http://172.17.0.2/;
}

On apache container, I have "/var/www/html/index.html" which has the following form.

<form action="act.php?action=add_item" method="post" ...

and I have corresponding "/var/www/html/act.php".

On some browser, it works perfect when I access "http://.../foo/" and the submit goes correctly. But on others, it doesn't work and I have to modify like this,

<form action="foo/act.php?action=add_item" method="post" ...

i.e., I have to attach "foo/". I don't know why, is there a way to fix this?

Thanks a lot for the help!

The solution was to change

<form action="act.php?action=add_item" method="post" ...

To

<form action="/foo/act.php?action=add_item" method="post" ...

This is because that page is accessed through /foo, so if you try to see /act.php you won't be able, because you are routing/proxing/rewriting to /foo to be able to see it. So correct path is absolute to /foo/act.php.