使用htaccess将动态URL重定向到另一个动态URL

编程入门 行业动态 更新时间:2024-10-18 02:34:35
本文介绍了使用htaccess将动态URL重定向到另一个动态URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试重定向动态网址,如下所示:

I'm trying to redirect a dynamic URL which is as follows:

example/manage/billing/invoice/all/viewinvoice.php?id = 1541

并且我需要它重定向到:

and I need it to redirect to:

example/manage/billing/invoice/1541/

我想使用.htaccess来实现

I want to do this using .htaccess

我已经做到了这一点,但似乎无法使它起作用:

I got as far as this but I cannot seem to get it to work:

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /manage/billing/invoice/all/viewinvoice\.php\?id=([^\ ]*) RewriteRule ^ /manage/billing/invoice/all/%1 [L,R=301]

有人有任何建议吗?

推荐答案

将其添加到Web根/目录中的 .htaccess 中

Add this to your .htaccess in your web root / directory

Options +FollowSymLinks -MultiViews # Turn mod_rewrite on RewriteEngine On RewriteBase / RewriteCond %{THE_REQUEST} ^GET\ /(.*?)/all/viewinvoice\.php\?id=([^&\s]+)&? [NC] RewriteRule ^ /%1/%2/? [L,R=301] RewriteRule ^(.*?/invoice)/([^/]+)/?$ /$1/all/viewinvoice.php?id=$2 [NC,QSA,L]

更多推荐

使用htaccess将动态URL重定向到另一个动态URL

本文发布于:2023-11-01 01:47:57,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1547893.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:动态   重定向   htaccess   URL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!