使用 .htaccess 通过 301 为 SEO 等重定向 404 错误

编程入门 行业动态 更新时间:2024-10-27 23:26:00
本文介绍了使用 .htaccess 通过 301 为 SEO 等重定向 404 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我找不到我的问题的直接答案,需要从真正的专家那里知道.

I couldn't find a straight answer to my question and need to know it from the real experts.

我有一个网站,其网址是由 Joomla 生成的.我相信搜索引擎中有大量的网址,但我真的不知道它们中的哪一个.302 重定向是一种选择,但我不能说需要重定向哪些网址.

I had a website which urls were generated by Joomla. I believe that tons of urls are around in the search engines and I really don't know which of them all. A 302 redirect would be an option, but I can't say which urls need to be redirected.

我唯一知道所有网址都是由 sef404 脚本生成的,它是 Joomla 的 SEO 脚本.

The only thing I know that all the urls were generated by a sef404 script, it's a SEO script for Joomla.

我的问题是,如何确保通过 .htaccess 文件正确传送 google 和其他搜索引擎上的所有孤立网址?

My question, how can I make sure that all the orphan urls on google and other search engines are delivered correctly with a .htaccess file?

如何将所有404页面301重定向到首页(根文档)

目前我使用的是自定义 404.html 错误文件,但是文件太多,会导致自定义 404 错误页面的过山车

At the moment I use a custom 404.html error file, but there are too many files and will give a rollercoaster of custom 404 error pages

推荐答案

您需要了解有关 URL 的信息,例如它们是否具有特定目录或某些查询字符串元素,因为您必须匹配某些内容.否则,您将不得不在 404 上重定向.如果这是必需的,那么在您的 .htaccess 中执行以下操作:

You will need to know something about the URLs, like do they have a specific directory or some query string element because you have to match for something. Otherwise you will have to redirect on the 404. If this is what is required then do something like this in your .htaccess:

ErrorDocument 404 /index.php

错误页面重定向必须相对于 root,因此您不能使用 www.mydomain.

An error page redirect must be relative to root so you cannot use www.mydomain.

如果您也有要匹配的模式,请使用 301 而不是 302,因为 301 是永久的,而 302 是临时的.301 会将旧网址从搜索引擎中删除,而 302 不会.

If you have a pattern to match too then use 301 instead of 302 because 301 is permanent and 302 is temporary. A 301 will get the old URLs removed from the search engines and the 302 will not.

Mod 重写参考:httpd.apache/docs/1.3/mod/mod_rewrite.html

更多推荐

使用 .htaccess 通过 301 为 SEO 等重定向 404 错误

本文发布于:2023-10-31 17:14:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1546746.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重定向   错误   htaccess   SEO

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!