繁体   English   中英

替换部分URL htaccess后重定向所有URL

[英]Redirect all urls after replace a part of url htaccess

我正在将php脚本从一个服务器目录迁移到另一个目录。 我试图为此编写一个htaccess规则。 当前网址如下

EX-

    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

新的新网址就像

EX-

    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才能正常工作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM