使用 htaccess 将包含特定部分的所有页面重定向到主页
Redirect all pages containing a particular part to home using htaccess
最近我的网站遭到黑客攻击,生成了大量页面。它们中的大多数以 ?_t=77
、?_t=97
和 ?_t=56
等字符串结尾。基本上,?_t=
部分在所有这些字符串中都很常见。
如何创建 .htaccess 规则以将所有带 ?_t=
的链接重定向到主页?
我已经创建的一些重定向:
<IfModule mod_rewrite.c>
RewriteEngine On
Redirect 301 /profile/1320172681 /u/DanLiu
Redirect 301 /profile/387899125 /u/LuckyMaheshwari
Redirect 301 /profile/15379797 /u/manishchopra
Redirect 301 /profile/335596945 /u/MatthewNord
Redirect 301 /profile/94097446 /u/abhimanyu
</IfModule>
谢谢
根据您显示的 attempts/samples,请尝试遵循 htaccess 规则。请确保在测试您的 URL 之前清除您的浏览器缓存。
<IfModule mod_rewrite.c>
##making your Rewrite engine ON here.
RewriteEngine On
##Rewriting urls with ending with ?_t=digits to home page here.
RewriteCond %{QUERY_STRING} ^_t=\d+/?$ [NC]
RewriteRule ^ / [R=301,L,QSD]
##Rewriting home page url to index.php here.
RewriteRule ^/?$ index.php [QSA,L]
###put your rest of htaccess Rules from here onwards.
Redirect 301 /profile/1320172681 /u/DanLiu
Redirect 301 /profile/387899125 /u/LuckyMaheshwari
Redirect 301 /profile/15379797 /u/manishchopra
Redirect 301 /profile/335596945 /u/MatthewNord
Redirect 301 /profile/94097446 /u/abhimanyu
</IfModule>
最近我的网站遭到黑客攻击,生成了大量页面。它们中的大多数以 ?_t=77
、?_t=97
和 ?_t=56
等字符串结尾。基本上,?_t=
部分在所有这些字符串中都很常见。
如何创建 .htaccess 规则以将所有带 ?_t=
的链接重定向到主页?
我已经创建的一些重定向:
<IfModule mod_rewrite.c>
RewriteEngine On
Redirect 301 /profile/1320172681 /u/DanLiu
Redirect 301 /profile/387899125 /u/LuckyMaheshwari
Redirect 301 /profile/15379797 /u/manishchopra
Redirect 301 /profile/335596945 /u/MatthewNord
Redirect 301 /profile/94097446 /u/abhimanyu
</IfModule>
谢谢
根据您显示的 attempts/samples,请尝试遵循 htaccess 规则。请确保在测试您的 URL 之前清除您的浏览器缓存。
<IfModule mod_rewrite.c>
##making your Rewrite engine ON here.
RewriteEngine On
##Rewriting urls with ending with ?_t=digits to home page here.
RewriteCond %{QUERY_STRING} ^_t=\d+/?$ [NC]
RewriteRule ^ / [R=301,L,QSD]
##Rewriting home page url to index.php here.
RewriteRule ^/?$ index.php [QSA,L]
###put your rest of htaccess Rules from here onwards.
Redirect 301 /profile/1320172681 /u/DanLiu
Redirect 301 /profile/387899125 /u/LuckyMaheshwari
Redirect 301 /profile/15379797 /u/manishchopra
Redirect 301 /profile/335596945 /u/MatthewNord
Redirect 301 /profile/94097446 /u/abhimanyu
</IfModule>