如何在HTACCESS文件中将此URL重定向到我的主页


How to Redirect this URL to my home page In HTACCESS file

我是PHP新手,我想通过编辑HTACCESS文件将此URL重定向到我的主页www.laroute-angkor.com

这里的网址,我想重定向时,访问者点击或访问:

www.laroute-angkor.com/component/k2/item/68-tours-by-sub-categories/68-tours-by-sub-categories?cat_id=23&start=5710http://www.laroute-angkor.com/component/k2/item/62-bakheng-mountain/62-bakheng-mountain?start=1222270http://www.laroute-angkor.com/component/k2/item/497-tours-by-sub-categories?cat_id=38http://www.laroute-angkor.com/component/k2/item/496-tours-by-sub-categories?cat_id=38

下面将把上面提到的所有4个链接重定向到您的索引页面。

Options +FollowSymLinks -MultiViews
RewriteEngine on
RewriteBase /
RewriteCond %{QUERY_STRING} ^cat_id=23&start=5710$
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/68-tours-by-sub-categories/68-tours-by-sub-categories/?$ /? [R=301,NC,L]
RewriteCond %{QUERY_STRING} ^start=1222270$
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/62-bakheng-mountain/62-bakheng-mountain/?$ /? [R=301,NC,L]
RewriteCond %{QUERY_STRING} ^cat_id=38$
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/49(6|7)-tours-by-sub-categories/?$ /? [R=301,NC,L]

注意:如果后面是什么?不重要,只是这样:

Options +FollowSymLinks -MultiViews
RewriteEngine on
RewriteBase /
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/68-tours-by-sub-categories/68-tours-by-sub-categories/?$ /? [R=301,NC,L]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/62-bakheng-mountain/62-bakheng-mountain/?$ /? [R=301,NC,L]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/49(6|7)-tours-by-sub-categories/?$ /? [R=301,NC,L]

2之间的区别是第二个将重定向:

http://www.laroute-angkor.com/component/k2/item/68-tours-by-sub-categories/68-tours-by-sub-categories?cat_id=23&start=5710

即使它在?之后有其他东西,所以基本上它可以是?之后的任何东西,并且它将重定向,而只有在?之后的东西与cat_id=23&start=5710完全相同的情况下,第一组规则才会重定向。