2014-02-12 72 views
0

我怎樣才能讓重寫規則/ variableusername - 網址www.example.com/variableusernameURL重寫規則

location /staticusername { 

      try_files $uri/ /admin/index.php?q=$uri&$args; 
    } 

如果我改變/ staticusername與我的一個用戶名的所有工作,就像我需要。但是當我嘗試用其他用戶名登錄時肯定不起作用。 那麼如何將每個用戶重寫爲/admin/index.php?q=$uri & $ args? 感謝您的任何意見

回答

0

如何:

location/{ 

    try_files $uri $uri/ /index.php; 
    index index.php index.html index.htm; 

    # rewriteRule: example.com/userName_0-9 
    rewrite ^/([A-Za-z0-9_]+)$ /admin/index.php?q=$1;  
}