2014-01-22 23 views
1

我現在htaccess的是這樣的:塊QUERY_STRING然後secified

RewriteCond %{QUERY_STRING} !^ts=.*$ [L] 
RewriteRule ^$ index.php? [L] 

RewriteRule ^index\.html$ index.php [NC,L] 
RewriteRule ^(set_language)-([a-zA-Z_0-9]+)\.html$ index.php?language=$2&%{QUERY_STRING} [NC,L] 
RewriteRule ^([a-zA-Z_0-9]+)-([a-zA-Z_0-9]+)\.html$ index.php?g1=$2&%{QUERY_STRING} [NC,L] 
RewriteRule ^([a-zA-Z_0-9]+)-([a-zA-Z_0-9]+)-([a-zA-Z_0-9]+)\.html$ index.php?g1=$2&province=$3&%{QUERY_STRING} [NC,L] 
RewriteRule ^([a-zA-Z_0-9]+)-([a-zA-Z_0-9]+)-([a-zA-Z_0-9]+)-([a-zA-Z_0-9]+)\.html$ index.php?g1=$2&g2=$4&%{QUERY_STRING} [NC,L] 
RewriteRule ^([a-zA-Z_0-9]+)-([a-zA-Z_0-9]+)-([a-zA-Z_0-9]+)-([a-zA-Z_0-9]+)-([a-zA-Z_0-9]+)-([a-zA-Z_0-9]+)\.html$ index.php?g1=$2&g2=$4&g3=$6&%{QUERY_STRING} [NC,L] 

前兩行是爲阻止QUERY_STRING。主要是對我的網頁鏈接是像

[TEXT]-[NUMBER].html 
[TEXT]-[NUMBER]-[TEXT]-[NUMBER].html 

等,有從接觸形式方含GET值

?ts=[NUMBER] 

我真的不知道如何阻止所有QUERY_STRING的除了從最後一個環節,一個一個環節。有人可以幫我解決這個問題嗎?

回答

1

how to block all QUERY_STRING's except the one from last link

使用此規則:

RewriteCond %{ENV:REDIRECT_STATUS} ^$ 
RewriteCond %{QUERY_STRING} .+ 
RewriteCond %{QUERY_STRING} !^ts=[^&]*$ [NC] 
RewriteRule^- [F] 
+0

幾乎工作,但現在它可以讓頁面只如果在查詢 「TS」。正如我所提到的只有一個頁面。基本上有兩種情況:QUERY中沒有QUERY(在「?」之後)鏈接,並且只有一個鏈接與「ts」鏈接。這是「!^(ts = [^&] *)?$」我在做什麼? – ThePueblo

+0

現在確定看到更新的答案。 – anubhava

+0

仍然不如預期,爲例: '調用「/」 - 正常工作「# '調用」/?ts = 123「 - 正常工作」# '調用「/some_text-12.html」 - 拋出錯誤# '調用「/some_text-12.html?ts=123」 - 拋出錯誤' 上面不應該拋出錯誤,應該拋出錯誤是例如:''/some_text-12.html?some_random=value「'和那些是那些我想擺脫的。 – ThePueblo