2014-01-31 24 views
1

我有規則如下所示:Apache的現代重寫規則打擾別人

Redirect 301 /example/test/54 http://newdomain.com.au?ref=hello54 
Redirect 301 /example/test/15 http://newdomain.com.au?ref=hello15 

然後我還有一個規則:那是不是第一規則捕獲

Redirect 301/http://newdomain.com.au?ref=test 

任何然後被最後一個捕獲。 問題是說,如果我做的:

http://olddomain.com/qwerty它重定向到http://newdomain.com.au/qwerty

我需要它只是重定向到http://newdomain.com.au/(而不是追加QWERTY)

回答

0

使用RedirectMatch用正則表達式的支持更精細的控制:

RedirectMatch 301 ^/example/test/54/?$ http://newdomain.com.au?ref=hello54 
RedirectMatch 301 ^/example/test/15/?$ http://newdomain.com.au?ref=hello15 
RedirectMatch 301 ^/?$ http://newdomain.com.au?ref=test