2016-07-16 27 views
2

背景如何呼籲基本URL不是當前URL

我這裏有一個URL一個PHP GET:

http://examplesite.com/first_name/last_name

這是由nginx的重定向到這樣的:

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

例如:

所以它就像http://examplesite.com/search.php?search_last=Smith&search_first=John,但看起來像http://examplesite.com/John/Smith

這是好作品,我有它,這樣它看起來更清潔

問題

如果有人在http://examplesite.com/John/Smith和點擊的形式提交像這樣:

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

它們轉發到

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

他們應該被轉發至:

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

問題

我如何做一個表單的頁面上,在此網址:

http://examplesite.com/John/Smith

附加GET參數/調用到URL http://examplesite.com/,而不是http://examplesite.com/John/

OR

如何打開

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

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

+1

你已經進入'/ search.php'不如行動,而不是'search.php'也而不是'。/ search.php'。 – christopher2007

回答

1

嘗試在你的HTML/PHP的`form`標籤改變action="search.php"action="../search.php"

+2

最好使用'action =「/ search.php」'來確定,它直接從根本上來看。 '../'在htaccess的重定向中可能會有其他一些問題。 – christopher2007

+1

工作,謝謝,當SO允許時,我會接受這個答案。 – Romulus