mod_rewrite显示重新编写的 URL


mod_rewrite reveals re written URL

我是URL重写的新手,所以我只是掌握了窍门。我遇到的问题是我的规则有效并拉取正确的页面,但在页面加载后,它会显示重写的 URL,而不是地址栏中的尾部斜杠。

RewriteEngine on 
RewriteBase /
RewriteRule   ^(.+)/(.+)/([0-9]+)$  ^testing.php?do=$1&see=$2&id=$3 [NC,L]

因此,我没有在地址栏中看到 http://www.example.com/walk/cars/9843928,而是看到 http://www.example.com/testing.php?do=walk&see=cars&id=9843928

我可以让它正常工作并在栏中保留尾部斜杠 URL 吗?

目标网址不应以^开头。

将您的代码替换为以下内容:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^([^/]+)/([^/]+)/([0-9]+)/?$ testing.php?do=$1&see=$2&id=$3 [L,QSA]