Match URLs with HTaccess for some strings but not others
I've been trying to figure this problem out for a while now. I've succeeded in referring all URLs from a two digit subfolder (ie the language folders) back to the main site. So I've got these a URL like this:
http://www.mysite.com/de/index.php&option=com_virtuemart&page=shop.browse&category_id=&product_type_id=1&product_type_1...etc
going to
http://www.mysite.com/index.php&option=com_virtuemart&page=shop.browse&category_id=&product_type_id=1&product_type_1...etc
using this HTacess line:
RedirectMatch 301 /../(.*)index.php(.*)$ http://www.mysite.com/$1
This was fine until recently when I've added an affiliate system which has urls starting with index.php and I'd like to make this component exempt from the rewrite rule.
In Summary, I'd like to be able to create a rule or match that matched URLs like :
http://www.mysite.com/de/index.p开发者_StackOverflowhp&option=com_virtuemart&page=shop.browse&category_id=&product_type_id=1&product_type_1...etc
but didn't match URLs like:
http://www.mysite.com/de/index.php?option=com_affiliate
and
http://www.mysite.com/de/index.php?option=com_affiliate&sec=banners
Thanks for your time in reading this. Ant.
Here is a link to my HTaccess file: http://www.seed-city.com/htaccess.txt
Using mod_rewrite
you can do the following:
RewriteEngine On
RewriteCond %{QUERY_STRING} !option=com_affiliate
RewriteRule [a-zA-Z]{2}\/(.*)$ /$1 [L]
Hope that helps.
精彩评论