我正在尝试重定向动态网址,如下所示:
http://example.com/manage/billing/invoice/all/viewinvoice.php?id=1541
我需要它重定向到:
http://example.com/manage/billing/invoice/1541/
我想用.htaccess
这样做我得到了这个,但我似乎无法让它工作:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /manage/billing/invoice/all/viewinvoice\.php\?id=([^\ ]*)
RewriteRule ^ /manage/billing/invoice/all/%1 [L,R=301]
有人有任何建议吗?
答案 0 :(得分:0)
将此添加到您的网络根.htaccess
目录
/
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]