使用 .htaccess 通过 301 为 SEO 等重定向 404 错误 [英] Redirecting 404 error with .htaccess via 301 for SEO etc

查看:37
本文介绍了使用 .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.com.

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

如果您也有要匹配的模式,请使用 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 重写参考:http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html

这篇关于使用 .htaccess 通过 301 为 SEO 等重定向 404 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆