Romulus Romulus - 4 months ago 10
PHP Question

How to call a PHP GET on the base URL not the current URL

Background

I have a URL here:

http://examplesite.com/first_name/last_name

This is redirected by nginx to this:

rewrite ^/(.*)/(.*) /search.php?search_last=$2&search_first=$1 last;


For example:

So it acts like http://examplesite.com/search.php?search_last=Smith&search_first=John but looks like http://examplesite.com/John/Smith

This is good and works and I have it so that it looks cleaner

Problem

If someone is at http://examplesite.com/John/Smith and clicks submit in a form like this:

<form class="navbar-form" action="search.php" method="GET">


They are forwarded to

http://examplesite.com/John/search.php?search_last=$2&search_first=$1

They should be forwarded to:

http://examplesite.com/search.php?search_last=$2&search_first=$1

Question

How do I make a form on a page at this url:

http://examplesite.com/John/Smith

attach the GET parameters/call to the url http://examplesite.com/ and not http://examplesite.com/John/

OR

How do I turn

http://examplesite.com/John/search.php?search_last=$2&search_first=$1

into

http://examplesite.com/search.php?search_last=$2&search_first=$1

Answer

Try changing action="search.php" to action="../search.php"