htaccess 将所有页面重定向到单个页面
我想使用 htaccess 文件将所有旧域请求重定向到新域。以下是我正在使用的内容,但如果该页面不在新网站上,它就不起作用。例如,谷歌索引 about.htm 在旧网站上,但在新网站上它不存在。我希望它在所有情况下都能找到根源。我知道这对于 seo 来说并不理想,但我不想要任何 404。有什么建议吗?
Redirect 301 / http://www.thenewdomain.com/
I want to redirect all of my old domain request to my new domain using htaccess file. Below is what I am using but it does not work if the page is not on the new site. For example google index about.htm on the old site but on the new site it does not exist. I would like it to just go to the root in all cases. I know this is not ideal for seo but I don't want any 404s. Any suggestions?
Redirect 301 / http://www.thenewdomain.com/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
如果您的目标是将所有页面重定向到单个维护页面(正如标题也可能暗示的那样),则使用:
其中 000 000 000 000 应替换为 您的 IP 地址。
来源:
http://www.techiecorner。 com/97/redirect-to-maintenance-page-during-upgrade-using-htaccess/
If your aim is to redirect all pages to a single maintenance page (as the title could suggest also this), then use:
Where 000 000 000 000 should be replaced by your ip adress.
Source:
http://www.techiecorner.com/97/redirect-to-maintenance-page-during-upgrade-using-htaccess/
您是否试图让 old.com/about.htm 的访问者转到 new.com/about.htm ?如果是这样,您可以使用 .htaccess 中的 mod_rewrite 规则来执行此操作:
Are you trying to get visitors to old.com/about.htm to go to new.com/about.htm? If so, you can do this with a mod_rewrite rule in .htaccess:
这会将旧主机的所有内容定向到新主机的根目录:
This will direct everything from the old host to the root of the new host:
HTAccess 将网站的所有页面发送到一页。这对我有用:
或对不同的域...
HTAccess to send all pages of a website to one page. This worked for me:
or to a different domain...
为当前不在您网站上的页面添加此...
ErrorDocument 404 http://example.com/
以及您的重定向 301 / http://www.thenewdomain.com/ 应该涵盖所有基础...
好运气!
Add this for pages not currently on your site...
ErrorDocument 404 http://example.com/
Along with your Redirect 301 / http://www.thenewdomain.com/ that should cover all the bases...
Good luck!