0

这是我的网址。我希望它通过路由更改 URL。https://www.example.com/view_retailer.php?rid=665 我想要这样的东西。 http://example.com/coupons-deals-cashback/AutoZone

请帮忙,我怎么能做到这一点。我使用 PHP 作为一种语言,我希望网站的其他部分保持不变,并使用此功能。

4

2 回答 2

2

有一个代码可以将查询字符串中的周长转换为变量。第一个变量将是页面,第二个将是 s,第三个将是 0。您现在不必在 URL 中使用查询字符串,但您可以通过执行检查请求的参数

echo "<pre>";
print_r($_REQUEST);
echo "</pre>";

.htaccess

RewriteEngine On

DirectoryIndex index.php

RewriteRule ^([a-zA-Z0-9_-]{3,20})/([^/]+)/([^/]+)?$ index\.php?page=$1&s=$2&o=$3 [L]

RewriteRule ^([a-zA-Z0-9_-]{3,20})/([^/]+)?$ index\.php?page=$1&s=$2 [L]

RewriteRule ^([a-zA-Z0-9_-]{3,20})/?$ index\.php?page=$1 [L]

RewriteRule ^([a-zA-Z0-9_-]{3,20})?$ index\.php?page=$1 [L]

ErrorDocument 404 /404
于 2013-05-28T11:34:07.697 回答
1

这需要在 apache 网络服务器的 .htaccess 文件中完成,或者在您使用的任何其他网络服务器的重写规则中完成。

于 2013-05-28T11:20:52.303 回答