使用htaccess将动态URL重定向到另一个动态URL [英] Redirecting a dynamic URL to another dynamic URL using htaccess

查看:59
本文介绍了使用htaccess将动态URL重定向到另一个动态URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

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

并且我需要它重定向到:

and I need it to redirect to:

http://example.com/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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆