2011-04-20 58 views
0

我一直在試圖解決這個問題一段時間。我成功地將兩位數子文件夾(即語言文件夾)中的所有網址引回主網站。所以,我有這些像這樣的URL:使用HTaccess爲一些字符串匹配URL但不是其他字符

RedirectMatch 301 /../(.*)index.php(.*)$ http://www.mysite.com/ $1

這都很正常,直到最近:

http://www.mysite.com/de/index.php&option=com_virtuemart&page=shop.browse&category_id=&product_type_id=1&product_type_1...etc

使用此HTacess線將

http://www.mysite.com/index.php&option=com_virtuemart&page=shop.browse&category_id=&product_type_id=1&product_type_1...etc

當我添加了一個以index.php開頭的url的聯盟系統,我想使該組件免於重寫規則。

總結,我希望能夠創建一個匹配的網址如下規則或比賽:

http://www.mysite.com/de/index.php&option=com_virtuemart&page=shop.browse&category_id=&product_type_id=1&product_type_1...etc

但不匹配像URL:

http://www.mysite.com/de/index.php?option=com_affiliatehttp://www.mysite.com/de/index.php?option=com_affiliate&sec=banners

感謝您的閱讀時間。螞蟻。

這裏是我的.htaccess文件的鏈接:http://www.seed-city.com/htaccess.txt

回答

0

使用mod_rewrite你可以做到以下幾點:

RewriteEngine On 
RewriteCond %{QUERY_STRING} !option=com_affiliate 
RewriteRule [a-zA-Z]{2}\/(.*)$ /$1 [L] 

希望有所幫助。

+0

嗨,謝謝你的迴應。我將它添加到我的htaccess文件中,但是我唯一能看到的結果是我的圖片沒有加載。我編輯了我的問題以顯示我的完整htaccess文件。如果我正確地理解了你的規則,那麼除了option = com_affiliate之外,是不是除了刪除lang文件夾以外的所有查詢,有沒有一種方法可以說是重定向index.php&option = com_virtuemart&page = shop.browse&category_id =&product_type_id = 1&product_type_1 ... etc'但不是'http://www.mysite.com/de/index.php?option = com_affiliate&sec = banners'命令對於您的規則的位置是否重要?再次感謝。 – Natastna2 2011-04-20 17:04:48

+0

@clmarquart你可以在上面看到我的htaccess文件?它的位置對它的工作很重要嗎?謝謝。 – Natastna2 2011-04-20 21:22:26

+0

訂單絕對重要。我所提供的將會將所有非'com_affiliate'鏈接重定向到一個語言文件夾(即'/ de /')到根目錄。從你的第一個評論,你是說你的網址沒有標準的??查詢字符串?並且他們從index.php後面的'&開始? – clmarquart 2011-04-21 00:28:43

相關問題