简单的.htaccess 301重定向多个页面

发布于 2024-12-24 02:32:24 字数 480 浏览 2 评论 0原文

所以我的 .htaccess 文件看起来像这样

RewriteBase /
Redirect 301 /page.html http://www.yoursite.com/newpage.html
Redirect 301 /page2.html http://www.yoursite.com/newpage.html

,它不会重定向我的 page.html

,如果我保留它,

RewriteBase /
Redirect 301 / http://www.yoursite.com/newpage.html

它就会工作,并重定向我的所有网站。现在为什么不起作用,相信我,我在 .htaccess 文件附近有 page.html,令人沮丧的是我有 10 个 .html 之类的东西要重定向,而不是更多......:(

任何人都可以帮助我吗?

So my .htaccess file looks like this

RewriteBase /
Redirect 301 /page.html http://www.yoursite.com/newpage.html
Redirect 301 /page2.html http://www.yoursite.com/newpage.html

and it doesn't redirect my page.html

and if i leave it

RewriteBase /
Redirect 301 / http://www.yoursite.com/newpage.html

it works, and redirect all my website. Now why is not working, and believe me, i have page.html near .htaccess file, and the frustation is that i have somthing like 10 .html to redirect, not more ... :(

Can anyone help me?

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

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

发布评论

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

评论(1

秉烛思 2024-12-31 02:32:24

要获得等效结果,您可以将其添加到任何其他规则之前的 .haccess 文件中。

RewriteEngine On
RewriteBase /

#redirect page or page2 .html
RewriteRule ^page(|2)\.html$ http://www.yoursite.com/newpage.html [NC,R=301,L]

To get the equivalent result you can add this to your .haccess file before any other rules.

RewriteEngine On
RewriteBase /

#redirect page or page2 .html
RewriteRule ^page(|2)\.html$ http://www.yoursite.com/newpage.html [NC,R=301,L]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文