URL重写的正则表达式有谁知道怎么写 在网上找了几个 都不能用
现在先用javascript来重写URL 以后估计会在IIS上做配置
现在只要先做到类似:
http://localhost/carsprice/InsurancePrice_New_Index2.aspxCity=1&CarState=1&Price=52.5&Seat=5&Carage=1&Company=TPY&Date=2008-3-1
重写成 :http://localhost/carsprice/InsurancePrice_New_Index2/City/1/CarState/1/Price/52.5/Seat/5/Carage/1/Company/TPY/Date/2008-3-1/ 就可以了
请知道的朋友说下 很急啊 !!!!!
谢谢 !!!!
现在先用javascript来重写URL 以后估计会在IIS上做配置
现在只要先做到类似:
http://localhost/carsprice/InsurancePrice_New_Index2.aspxCity=1&CarState=1&Price=52.5&Seat=5&Carage=1&Company=TPY&Date=2008-3-1
重写成 :http://localhost/carsprice/InsurancePrice_New_Index2/City/1/CarState/1/Price/52.5/Seat/5/Carage/1/Company/TPY/Date/2008-3-1/ 就可以了
请知道的朋友说下 很急啊 !!!!!
谢谢 !!!!
你能确保这些目录都存在 ?
.aspx? --> /& ---> /= ---> /
js replace 就可以了
红色的?应该是有的吧?
// http://localhost/carsprice/InsurancePrice_New_Index2/City/1/CarState/1/Price/52.5/Seat/5/Carage/1/Company/TPY/Date/2008-3-1/
//str = str.replace(/[(.asp\?)=&]/,"/")
str = str.replace(/[\?&](.*?)=(.*?)/g,"/$1/$2")
document.write(str)
str = str.replace(/(.*?)(\.aspx)(.*?)/g,"$1$3")
document.write(str)
以后肯定还是要在IIS中来配置的 这样可以批量处理 而且不用考虑参数的因数
RewriteRule /news/(\d+)\.html /news\.asp\?id=$1 [N,I]
这样就把 /news/234.html 这样的请求映射成了 /news.asp?id=234
当有对/news/234.html的请求时:web服务器会把实际请求转发给/news.asp?id=234
比对于某一个简单应用可以是:
RewriteRule /news/(\d+)\.html /news/news\.php\?id=$1 [N,I]
这样就把 http://www.xxxxxx.com/news/234.html 映射到了 http://www.xxxxxx.com/news/news.php?id=234
一个更通用的能够将所有的动态页面进行参数映射的表达式是:
把 http://www.xxxxxx.cn/foo.php?a=A&b=B&c=C
表现成 http://www.xxxxxx.cn/foo.php/a/A/b/B/c/C
RewriteRule (.*?\.php)(\?[^/]*)?/([^/]*)/([^/]*)(.+?)? $1(?2$2&:\?)$3=$4?5$5: [N,I]
3、使用URL重写功能的好处:
首先,有助于增加网站的安全性,因为它隐藏了诸如asp php jsp等相关的服务器技术,以最原始的html文件形式,呈现于客户。
其次,在平台移植时,不会各页面的网站。如将news.asp?id=123转移news.php?id=123,即将asp平台转移php,如使用此URL重写,这个页面的网址就是news/123.html。
其它方面,方便URL引用,有助于搜索引擎的枚举。
// http://localhost/carsprice/InsurancePrice_New_Index2/City/1/CarState/1/Price/52.5/Seat/5/Carage/1/Company/TPY/Date/2008-3-1/
//str = str.replace(/[(.asp\?)=&]/,"/")
str = str.replace(/[\?&](.*?)=(.*?)/g,"/$1/$2")
document.write(str)
str = str.replace(/(.*?)(\.aspx)(.*?)/g,"$1$3")
document.write(str)
我现在用了 Rewrit.dll 是根据网站上说的配的 但是没有效果
现在很迷茫 是否要修改httpd.ini文件?
或者那位知道如何配置IIS 有详细资料的给小弟我说下 感激不进啊 !!!!