php - Rewrite URL and pass a variable

I have a PHP page: site.com/page.php?city=variable
I would like the URL to look like this: site.com/your-city-variable
My .htaccess has this:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
RewriteRule ^your-city-([^/]+)/?$ page.php?city=$1
This works fine. The URL is rewritten and redirected. However the city variable is displayed as City.php on the page. (There is a .php extension appended to the city name) I would like the extension to not be appended to the variable.
Thank you.
Answer
Solution:
Problem solved. I moved this line to the top of .htaccess file:
RewriteRule ^your-city-([^/]+)/?$ page.php?city=$1
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: call to undefined function mysqli_connect()
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.