.htaccess - 使用 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>
谢谢
解决方案
使用您显示的尝试/示例,请尝试遵循 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>
推荐阅读
- android - 辅助显示器 DisplayMetrics 依赖于主显示器?
- arrays - 使用可观察函数数组,每个项目输出是下一个项目输入
- angular - 以编程方式设置动态添加的子组件的属性
- list - Thymeleaf ,地图对象,其值为地区列表。?
- python - 将 Jupterlab ipynb 转换为可执行文件
- vagrant - Vagrant IP 地址冲突问题
- c# - 如何让 LookAt 对齐 transform.up 向量而不是 transform.forward?
- g++ - G++ 没有找到 CoInitializeEx(和其他几个函数)?
- c# - 如何使用 Livecharts 使 x 轴从 0 开始并有 2 秒的步长,而不是盯着程序开始的一秒?
- swift - Playground simple Date() 正在打印考虑到我的时区的值