Redirect URL to homepage with trailing dots

Google webmaster shows several duplicate URLs, they

www.abc.com/index.php?option=com_toys&view=detail&n_id=148&ite.. www.abc.com/index.php?option=com_toys&view=detail&n_id=156&item.. www.abc.com/index.php?option=com_games&view=detail&vid=170&itemid.. www.abc.com/index.php?option=com_play&view=detail&vid=175&it.. 

To remove them - I believe the best way is to redirect to the home page any URL containing .. at the end of the URL

I tried to put this condition, but it does not work either

  RewriteRule ^(.*)\.htm$ http://www.abc.com/$1 [R=301,L] RewriteRule ^(.*)$ http://www.abc.com/$1 [L,R=301] RewriteRule ^(..*)\.htm$ http://www.abc.com/$1 [R=301,L] 

The correct URL structure

  www.abc.com/index.php?option=com_toys&view=detail&n_id=148&Itemid=2 www.abc.com/index.php?option=com_toys&view=detail&n_id=156&Itemid=2 www.abc.com/index.php?option=com_games&view=detail&vid=170&Itemid=3 www.abc.com/index.php?option=com_play&view=detail&vid=175&Itemid=4 

any suggestions pls ... many thnx

Edit September 13 Hi Anubhav,

If we redirect these URLs to page 404, then below the command in the correct htaccess

  RewriteCond %{THE_REQUEST} \?.+?\.\. RewriteRule ^index\.php$ - [NC,L,R=404] 
+4
source share
1 answer

Include mod_rewrite and .htaccess through httpd.conf , and then put this code in .htaccess in the DOCUMENT_ROOT directory:

 Options +FollowSymLinks -MultiViews # Turn mod_rewrite on RewriteEngine On RewriteBase / RewriteCond %{THE_REQUEST} \?.+?\.\. RewriteRule ^ /? [R=301,L,NE] 
+1
source

Source: https://habr.com/ru/post/1489396/


All Articles