我有一个带有一个GET参数的页面:reference
。
填写表格后,我现在的网址如下:
https://www.my-website.com/directory/hw/?referentie=29384
现在我希望将其更改(仅限于此特定tracking
页面):
https://www.my-website.com/hw/tracking/29384
.htaccess如何实现这一目标?
我当前的.htacess文件(位于/directory
)如下所示:
RewriteEngine On
RewriteRule ^tracking tracking.php [NC,L]
</IfModule>
这会将页面重定向到.php,而不必写下.php。
我尝试了以下操作(没有成功):
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^tracking tracking.php [NC,L]
RewriteRule ^tracking/(.*)$ tracking.php?reference=$1 [QSA]
</IfModule>
答案 0 :(得分:1)
RewriteEngine On
RewriteRule ^tracking/?$ tracking.php [NC,L]
RewriteCond %{THE_REQUEST} tracking/?\d*\?referentie=(\d+) [NC]
RewriteRule ^ /hw/tracking/%1? [R=301,L]
RewriteRule ^(tracking)/(\d+)$ $1.php?referentie=$2 [NC,L]