我启用了 mod rewrite 以删除所有页面扩展......
这是在 httpd.conf 中完成的,因为我在 Windows 上使用 apache
我的设置是
<IfModule mod_rewrite.c>
Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([^\.]+)$ $1.html [NC,L]
</IfModule>
这使得domain.com/bookings.html
显示为domain.com/bookings
我在 html 文件中启用了 php,因此它会解析所有页面的 php
但我现在在我的网站上放了一个搜索框,如果我搜索“音乐”,它将使用以下网址:
domain.com/search?q=music
我希望我的网址看起来像:
domain.com/search/music
而且,我希望能够输入
domain.com/search/abba
它会加载页面“search.html”,我们称之为“search”,它会添加参数 ?q=abba ,但在 URL 栏中仍然看起来像上面的示例
我确信这可以通过 mod rewrite 来实现,但我不知道如何表达这个表达式。
提前感谢我收到的任何帮助:)