2014-01-09 22 views
0

我試圖重寫動態URL短網址,沒有運氣短網址 的網址是http://exmple.com?user=username如何nginx的

我曾嘗試

rewrite ^/(.*)$ /index.php?user=$1; 

我想簡短它:

http://exmple.com/site/user name 

於是兩個問題:

  1. ,如果我的短網址http://exmple.com/username 我如何使用其他網址查詢,如http://exmple.com?search=something

  2. 我可以怎樣做呢?:)

我haved到處去尋找答案,並找到所以沒有什麼你並欣賞幫助

回答

0
RewriteRule ^/(\/index\.php\?user=)([A-Za-z0-9_-]+)/$ /site/$1 
+0

未知的指令重寫規則 – user3040832

+0

這是'apache'格式,請注意,這個問題被標記爲'nginx' –

0
location = /index.php { 
    rewrite^/site/$arg_user; 
} 
+0

nothing..other選項? – user3040832

+0

@ user3040832,你是什麼意思,「沒有」?請更具體。 – cnst

0

如果我假設,當有的/site然後總是接踵而來的是那麼的用戶名爲此

location ^~ /site/(.*) { 
    try_files /index.php?user=$1&$query_string =404 
}