.htaccess 使用指向page.php的1个参数编写干净的URL

.htaccess 使用指向page.php的1个参数编写干净的URL,.htaccess,clean-urls,.htaccess,Clean Urls,我想当访客键入http://localhost/mywebsite/paris/ 它调用http://localhost/mywebsite/page.php?city=paris 但是当键入http://localhost/mywebsite/ 它调用http://localhost/mywebsite/index.php RewriteEngine On RewriteRule ([a-zA-Z-]*) /page.php?city=$1 [QSA,L] 我得到以下错误: Not Foun

我想当访客键入
http://localhost/mywebsite/paris/
它调用
http://localhost/mywebsite/page.php?city=paris

但是当键入
http://localhost/mywebsite/
它调用
http://localhost/mywebsite/index.php

RewriteEngine On
RewriteRule ([a-zA-Z-]*) /page.php?city=$1 [QSA,L]
我得到以下错误:

Not Found
The requested URL was not found on this server.

请分享更多细节。为什么要
http://localhost/mywebsite/
如果您没有为索引定义任何规则,是否会生成索引以外的内容?您的要求是匹配
http://localhost/mywebsite/paris/
请不要只发布代码作为答案,还要解释代码的作用以及如何解决问题。带有解释的答案通常更有帮助,质量更好,更容易吸引选票。
RewriteRule ^([a-zA-Z0-9]+)$ page.php?city=$1
RewriteRule ^([a-zA-Z0-9]+)/$ page.php?city=$1