我正在将一个 php 脚本迁移到一个服务器目录到另一个目录。我试图为此编写一个htaccess规则。 当前的网址如下所示
前任-
https://www.example.com/scripts/tracking/inex.php
https://www.example.com/scripts/tracking/agency/invoice.php
https://www.example.com/scripts/tracking/admin/manage.php
新的新网址就像
前任-
https://www.example.com/dashboard/index.php
https://www.example.com/dashboard/agency/invoice.php
https://www.example.com/dashboard/admin/manage.php
有很多像上面这样的网址,所以很难写一对一的重定向到每个网址。
无论如何,是否可以将脚本/跟踪部分替换为仪表板并重定向到替换的URL。
我用过这个,但似乎不起作用
RedirectMatch 301 /scripts/tracking(.*) /dashboard/$1
有人帮我写这个,谢谢
RedirectMatch permanent "^scripts/tracking/(.*)" "/dashboard/$1"
您需要mod_alias才能正常工作。
RewriteEngine on
RewriteRule ^scripts/tracking/(.*) /dashboard/$1 [L,R=301]
您需要mod_rewrite才能正常工作。