bdbai
V2EX  ›  问与答

问一个 URL 重写(正则)的问题

  •  
  •   bdbai · Jul 18, 2015 · 2008 views
    This topic created in 3979 days ago, the information mentioned may be changed or developed.

    原 URL :

    api/userdata/profile?user_id=1&var2=value2

    希望重写到:

    apirouter.php?module=userdata&action=profile&user_id=1&var2=value2

    所以在.htaccess里面:

    RewriteRule ^.*?api/(.*?)/(.*?)\?(.*)$ apirouter.php?module=$1&action=$2&$3 [L]

    然而并不能识别,求正确姿势?

    2 replies    2015-07-18 00:46:47 +08:00
    yakczh
        1
    yakczh  
       Jul 18, 2015
    RewriteEngine on
    RewriteRule api/(userdata)/(profile) apirouter.php?module=$1&action=$2 [QSA,L]
    bdbai
        2
    bdbai  
    OP
       Jul 18, 2015 via iPhone
    @yakczh 原来的尾巴也要一起带上 这样可以?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5496 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 81ms · UTC 07:06 · PVG 15:06 · LAX 00:06 · JFK 03:06
    ♥ Do have faith in what you're doing.