通过 301 使用 .htaccess 重定向 404 错误以进行 SEO 等

发布于 2024-08-24 06:26:14 字数 363 浏览 5 评论 0原文

我无法找到问题的直接答案,需要从真正的专家那里了解答案。

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

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

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

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

目前我使用的是自定义404.html错误文件,但是文件太多,会出现自定义404错误过山车般的情况页面

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

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.

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

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?

How do I 301 redirect all 404 pages to the homepage (root document)

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

妥活 2024-08-31 06:26:14

我想出了解决方案并将其发布在我的博客上

http://web.archive.org/web/20130310123646/http://onlinemarketingexperts.com.au/2013/ 01/how-to-permanently-redirect-301-all-404-missing-pages-in-htaccess/

这里也是 htaccess 代码

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . / [L,R=301]

,但我也在我的博客上发布了其他解决方案,这取决于您真正需要什么

I came up with the solution and posted it on my blog

http://web.archive.org/web/20130310123646/http://onlinemarketingexperts.com.au/2013/01/how-to-permanently-redirect-301-all-404-missing-pages-in-htaccess/

here is the htaccess code also

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . / [L,R=301]

but I posted other solutions on my blog too, it depends what you need really

薯片软お妹 2024-08-31 06:26:14

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

ErrorDocument 404 /index.php

错误页面重定向必须相对于根目录,因此您无法使用 www.mydomain.com。

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

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

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

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

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 Rewrite Reference: http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文