Domanda

Pl advise, we made a mistake in creating lot of duplicate content for site in a section usedtoys How to use htaccess to remove :- 'brand' & 'location' from url & redirect to correct url

For eg. correct url

   http://www.abc.com/index.php?option=com_toys&view=category&Itemid=3

Incorrect URL

 http://www.abc.com/index.php?option=com_toys&view=category&Itemid=3&brand=1
 http://www.abc.com/index.php?option=com_toys&view=category&Itemid=3&brand=1&location=delhi

or Correct URL

   http://www.abc.com/index.php?option=com_toys&view=category&Itemid=3&limitstart=45

Incorrect URL

     http://www.abc.com/index.php?option=com_toys&view=category&Itemid=3&brand=1&limitstart=45
     http://www.abc.com/index.php?option=com_toys&view=category&Itemid=3&brand=1&location=delhi&limitstart=45

How to create a 301 redirect in htaccess so that any url having com_toys - with brand and/or location can be stripped and redirected to there correct url.

È stato utile?

Soluzione

Try:

RewriteEngine On

RewriteCond %{QUERY_STRING} (^|&)option=com_toys(&|$)
RewriteCond %{QUERY_STRING} ^(.*)&brand=([^&]+)(.*)$
RewriteRule ^index\.php$ /index.php?%1%3 [L,R=301]

RewriteCond %{QUERY_STRING} (^|&)option=com_toys(&|$)
RewriteCond %{QUERY_STRING} ^(.*)&location=([^&]+)(.*)$
RewriteRule ^index\.php$ /index.php?%1%3 [L,R=301]

in the htaccess file in your document root, preferably above any rules that you already have.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top