如何重定向以下示例:
http://www.mypage.tld/media/optivo/ch/de/?id=0805610075C6000
到
http://www.mypage.tld/media/optivo/ch/de/0805610075C6000.xml
因此参数值应为扩展名为.xml的文件名
我试过了:
RewriteCond %{QUERY_STRING} (?:^|&)id=([^&]+)
RewriteRule ^media/optivo/ch/de/$ $0%1.xml [L,R=permanent]
答案 0 :(得分:0)
RewriteEngine on
# capture the value of id parameter
RewriteCond %{QUERY_STRING} (?:^|&)id=([^&]+)
# for a .htaccess in root directory
RewriteRule ^media/optivo/ch/de/(?:index\.php)?$ $0%1.xml [L,R=permanent]
# for a .htaccess located in de subdirectory
#RewriteRule ^(?:index\.php)?$ %{REQUEST_URI}%1.xml [L,R=permanent]