2014-09-22 27 views
0

我試圖做一個重寫規則,但不可能找到正確的表達式。我一直在尋找不同類型的正則表達式驗證器,他們說這個表達式很有用。.httaccess重寫規則條件不起作用

.htaccess如下所示:

Options +FollowSymlinks -MultiViews -Indexes 
DirectoryIndex index.php index.html index.htm 
RewriteEngine on 
RewriteBase/
RewriteRule ^index\.php(.+)=([a-zA-Z]+)&([a-z]+)=([a-zA-Z]+)&([a-z]+)=([a-zA-Z]+)&([a-z]+)=(.*)$ /$3+$5+$7 [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 

的例子URI是:http://www.example.com/index.php?r=site/action&param1=value1

回答

1

在重寫規則中無法匹配查詢字符串,您需要使用%{QUERY_STRING}%{THE_REQUEST}變量。

雖然這是完全不清楚你想要做什麼,嘗試這樣的事情:

Options +FollowSymlinks -MultiViews -Indexes 
DirectoryIndex index.php index.html index.htm 
RewriteEngine on 
RewriteBase/

RewriteCond %{THE_REQUEST} \ /+index\.php\?(.+)=([a-zA-Z]+)&([a-z]+)=([a-zA-Z]+)&([a-z]+)=([a-zA-Z]+)&([a-z]+)=(.*) 
RewriteRule^/%3+%5+%7 [L] 
+0

我想要做的是,重寫規則由我想要的參數應用替代的URI。 P.ex.用/ value1替換/index.php?r=site/action¶m1=value1。感謝您的回答! – 2014-09-23 08:27:47