.htaccess - 使用指向 page.php 的 1 个参数编写干净的 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 Found
The requested URL was not found on this server.

最佳答案

RewriteRule ^([a-zA-Z0-9]+)$ page.php?city=$1
RewriteRule ^([a-zA-Z0-9]+)/$ page.php?city=$1

https://stackoverflow.com/questions/64422226/

相关文章:

reactjs - 我怎么能告诉 typescript Prop 来自 react 克隆元素?

android - 如何从 Android 应用程序内部了解用户谷歌播放国家/地区?

javascript - 使用 React 根据另一个下拉列表更新选择的选项

r - 如何使用 ggplot 自定义多面图中的背景颜色

python - 使用 python 控制包的错误奈奎斯特图

json - Angular environment.ts 问题 JSON。然而 environme

MongoDB Atlas 搜索 - 搜索字符串中的多个术语具有 'and' 条件(不是 'or'

python - 挣扎于基本的数据帧操作(Python)

azure - Terraform 对动态资源的 ignore_changes

google-sheets - Google 表格中的 ArrayFormula 和 "AND"公式