日期:2014-05-17  浏览次数:21048 次

ISAPI_ReWrite能不能实现这个问题?
www.**.com/SG/aaa.asp?id=1
www.**.com/HK/aaa.asp?id=1

(.*)/(\d)+/aaa.html   $1/HK/aaa.asp?id=$2

这样就可以达到使用www.**.com/SG/1/aaa.html来访问www.**.com/SG/aaa.asp?id=1的目的了,但是能否使用正则表达式写出来这样的url来:

www.**.com/singapore/1/aaa.html     访问   www.**.com/SG/aaa.asp?id=1
www.**.com/HongKong/1/aaa.html     访问   www.**.com/HK/aaa.asp?id=1

其实也就是countryCode有变化.SG-> singapore,HK-> hongkong.
我现在的做法是
(.*)/singapore/(\d)+/aaa.html       $1/SG/aaa.asp?id=$2
(.*)/hongkong/(\d)+/aaa.html       $1/HK/aaa.asp?id=$2

但是这样就比较麻烦,每个country都要写一次.不知道有没有通用的方法?

------解决方案--------------------
其实你自己尝试一下就知道了。
写完以后用javascript测试
首先,alert(location.href);
然后,alert(document.URL);
第一个显示地址栏里的地址,
第二个显示url重定向后的地址。
------解决方案--------------------

可不可以定义一个数组, 比如

(.*)/arr[0]/(\d)+/aaa.html $1/arr[1]/aaa.asp?id=$2