本文介绍了使用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
发布评论