Apache mod重写 - 动态URL到语义URL



我有一个基于Google Maps的小网络应用程序。我有这样的URL:

http://www.example.com/web.php?u=olives-restaurante-de-ensaladas-en-margarita

我想完全有:

http://www.example.com/web/olives-restaurante-de-ensaladas-en-margarita

所以我想将我的参数dynamic URLs转换为semantic URLs

我该如何实现?!

我试图将以下代码放在我的.htaccess

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^web/([A-Z0-9]+)/$ web.php?u=$1

但可悲的是,当我尝试访问http://www.example.com/web/olives-restaurante-de-ensaladas-en-margarita时,它将我重定向到404页。

我做错了什么?

RewriteRule ^web/([A-Z0-9]+)/$ web.php?u=$1
http://www.ubikate.com.ve/web/olives-restaurante-de-ensaladas-en-margarita

您的 RewriteRule 模式(^web/([A-Z0-9]+)/$(不允许连字符,执行拖延斜线,仅与大写字母匹配,因此这与您要求的URL匹配。

尝试以下内容:

RewriteRule ^web/([w-]+)$ web.php?u=$1 [L]

w是一个速记字符类,等效于[a-zA-Z0-9_]

最新更新