简体   繁体   English

使用.htaccess从mypage.domain重定向到mypage.domain / page

[英]Redirect from mypage.domain to mypage.domain/page with .htaccess

as the title says I would like to redirect from: mypage.domain to mypage.domain/page 如标题所示,我想从以下位置重定向: mypage.domainmypage.domain / page

I already tried this: 我已经尝试过了:

RewriteEngine On
RewriteBase /
Redirect 301 / http://www.mypage.domain/page

And I get an error that the page isn't redirecting properly, and also the url points to something like: 而且我收到一个错误,指出页面未正确重定向,并且URL也指向类似以下内容:

www.mypage.domain/pagepagepagepagepagepagepagepage

Can someone help me please? 有人能帮助我吗? Thanks in advance. 提前致谢。

You are doing it wrong. 你做错了。 301 status code is used for permanent redirect and here you are redirecting it to the same domain again. 301状态代码用于永久重定向,在这里您将其再次重定向到同一域。 So when the first redirect happens, it again comes to mypage.domain and then again the .htaccess file is consulted and again a redirect happens. 因此,当第一次重定向发生时,它再次进入mypage.domain,然后再次查询.htaccess文件,并再次发生重定向。 Hence in a way it goes into a loop. 因此,它以某种方式进入循环。

A proper 301 redirect should be done in the following way: 适当的301重定向应通过以下方式完成:

Redirect 301 / http://mynewpage.domain/

What you need here is to redirect the landing page to a specific sub folder in the root directory. 您需要在此处将登录页面重定向到根目录中的特定子文件夹。 Something of the following sort would work for you: 以下内容将为您工作:

Redirect /index.html http://mypage.domain/page/

Here the index.html can be your any landing page. 在这里index.html可以是您的任何登录页面。 It can be index.php etc. 可以是index.php等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM