1

我正在尝试重定向一个动态 URL,如下所示:

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]

有人有什么建议吗?

4

1 回答 1

0

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

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]
于 2013-08-25T19:22:58.487 回答