服務項目:網站建設、仿站、程序開發、APP開發設計、移動網站開發設計、企業網站設計、電子商務網站開發、網站維護、網站推廣、UX/UI 、HTML5、CSS3、JS / Jquery ...
          四川浚浚科技有限公司
          四川浚浚科技有限公司 (開發設計官網)TEL : 15308000360 / QQ : 38585404

          您的位置:首頁 > 技術經驗 > 服務器 > 正文

          Apache Rewrite ? 匹配問號的寫法
          技術支持服務電話:15308000360 【7x24提供運維服務,解決各類系統/軟硬件疑難技術問題】

          把 /abc?id=123  =>  /def.php?id=123 的寫法:

           
          RewriteEngine on
          RewriteCond %{QUERY_STRING} ^id=(.+)$
          RewriteRule ^/abc$ /def.php?sid=%1 [L]

          若此篇文章還不能解決您的問題,請聯系QQ:38585404  (有償技術支持)
           
          RewriteRule 不會去匹配 ? 后面的字符串,需要用RewriteCond來匹配
          參考:http://lists.apple.com/archives/web-dev/2006/Mar/msg00005.html
           
          附件:
          1樓:
          Options +FollowSymlinks
          RewriteEngine on
          # Set the RewriteBase to "/" for the root level to base everything on... I guess.
          RewriteBase /
          RewriteRule ^oldpage.php(.+) newpage.php$1&otherid=0 [R]
          -------------------------------------------------
          The $1 should have all the variable stuff in it from the php.
          So I'm looking for it to essentially do this:
          oldpage.php?id=1 redirects to newpage.php?id=1&otherid=0
          Why is this not working? Any help would be appreciated.
           
          2樓:
          Because the RewriteRule directive doesn't parse anything beyond the path portion of the requested URL. If you want to capture the query string, you have to use a RewriteCond statement to store the query string in a regex back-reference. You can then make use of the RewriteCond's back-references in a succeeding RewriteRule statement. There's actually a shortcut for doing this (check the QSA flag in the mod_rewrite docs), but you need to modify the query string in the rewritten URL, so you can't use that.
           
          Give this a try:
           
          RewriteCond %{QUERY_STRING} ^(.+)$
          RewriteRule ^oldpage.php newpage.php?otherid=0&%1 [R]
           
          -Brian
           
          3樓:
          So I fiddled around and came up with this:
           
          RewriteRule ^oldpage.php newpage.php?otherid=0 [QSA,R]
           
          Why does this work? The only thing I can figure is that the query 
          string is simply added to the end (as is says in the docs) of the new 
          page. But I'm not even referencing the query string in the first 
          part. Do I not need to do that? Does QSA take whatever the query 
           
          4樓:
          Hey,
          mod_rewrite is the swiss army knife of web deployment, so how could this be
          OT? ;-)
           
          Firstly, you're missing a question mark in your rewrite rule, every request
          will at least start with a SLASH (/) and then adding QSA to your rewrite
          rule might help in passing over query strings.
          (QSA = QeryStringAppend)
           
          ^ matches the begining of the requested URI which will always start with a
          slash as in: 
          http//www.apple.com/hardware
          ^ protocol
          ^ host
          ^ requested URI including /
           
          So give this a try:
           
          RewriteRule ^/oldpage.php(.*) newpage.php?$1&otherid=0 [QSA,R]
          ^ ^ ^^^
          this is needed you missed this this QSA is new
           
          or even
          RewriteRule ^/oldpage.php(.*) newpage.php?$1&otherid=0 [QSA,R=301]
          (R=301 makes the redirect a PERMANENT redirect)
           
          I'd even go so far to add a Rewrite Condition, so the rule doesn't have to
          be run for all requests:
           
          RewriteCond %{REQUEST_URI} ^/.*\.php.* [NC]
          RewriteRule ^oldpage.php(.*) newpage.php?$1&otherid=0 [QSA,R=301]
           
          ([NC] turns on case insensitivenes on the matches so .PHP=.php etc.)
           
          Also to debug problems with ModRewrite, it realy helps turning logging on to
          see what is actualy happening:
           
          RewriteLog "/var/log/httpd/rewrite.log"
          RewriteLogLevel 13



          上一篇:安裝PHP組件uploadprogress
          下一篇:vsftp不能上傳下載問題解決

          相關熱詞搜索:apache rewrite 偽靜態
          主站蜘蛛池模板: 青青草原综合网| 中文字幕亚洲乱码熟女一区二区| 男人桶进女人p无遮挡小频| 国产一区二区三区在线免费 | 92国产精品午夜福利| 好男人资源在线观看好| 中文无遮挡h肉视频在线观看| 日韩黄色免费观看| 亚洲免费视频网站| 欧美疯狂性受xxxxx另类| 亚裔玉videoshd和黑人| 精品久久人妻av中文字幕| 四虎国产精品永久在线网址| 野花影院在线直播视频| 国产成人v爽在线免播放观看| 中文字幕丝袜诱惑| 不卡无码人妻一区三区音频| 91福利视频合集| 99精品国产在热久久无毒不卡| 日本理论片午午伦夜理片2021| 亚洲乱码中文字幕小综合| 欧美激情综合网| 亚洲综合久久精品无码色欲| 男女裸体影院高潮| 出差被绝伦上司侵犯中文字幕| 中文字幕一区日韩精品| 日韩大乳视频中文字幕| 亚洲av日韩aⅴ无码色老头| 欧美又粗又长又爽做受| 亚洲婷婷第一狠人综合精品| 欧美超强性xxxxx| 亚洲激情黄色小说| 波多野结衣作品大全| 日产乱码一卡二卡三免费| 久久精品美女视频| 校花哭着扒开屁股浣肠于柔| 亚洲啪啪综合AV一区| 欧美成a人片在线观看久| 亚洲欧美一区二区三区孕妇| 欧美精品偷自拍另类在线观看| 亚洲欧美视频一级|