如何将旧域的目录索引重定向到 .htaccess 中的新域页面?
How can i redirect the directory index of my old domain to a new domain page in .htaccess?
我的一般问题是如何将我的旧域的目录索引重定向到新的域目录索引,就像我重定向网站上的另一个页面一样?
我能够了解如何通过一个重定向将我的新域上的所有单独页面。我的 htacess 代码如下所示
RewriteCond %{HTTP_HOST} ^example-page.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.example-page.com
DirectoryIndex front_page.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule /about /about_page.php
redirect 301 /about https://www.new_domain_example.com/about
我遇到问题的地方是重定向位于 https://www.example-page.com.
的主页或目录索引
我试过了
redirect 301 / https://www.example-page.com
还有
Redirect 301 http://www.example-page.com http://www.new_domain.com
第一个不起作用,因为该域的所有页面似乎都是不需要的。我只想将在 url 找到的 DirectoryIndex/ 主页重定向到新的 url.
第二次尝试也不行。在这一点上,我对我能做什么感到很困惑,我唯一想到的就是将主页外部化。这样看起来像。
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule /front /front_page.php
redirect 301 /front https://www.new_domain_example.com/front
我确定这不是必需的,我遗漏了一些东西。您将如何在不破坏我的其余代码的情况下重定向作为此代码中的目录索引的首页?
对于我做错了什么的任何帮助或见解将不胜感激。
如果您只想重定向主页,请尝试:
RewriteCond %{REQUEST_URI} ^\/.front_page\.php$
RewriteCond %{HTTP_HOST} !^newdomain\.com$
RewriteRule ^ https://newdomain.com%{REQUEST_URI} [R=301,L]
如果您想将旧域中的所有内容重定向到新域:
RewriteCond %{HTTP_HOST} !^newdomain\.com$
RewriteRule ^ https://newdomain.com%{REQUEST_URI} [R=301,L]
我的一般问题是如何将我的旧域的目录索引重定向到新的域目录索引,就像我重定向网站上的另一个页面一样?
我能够了解如何通过一个重定向将我的新域上的所有单独页面。我的 htacess 代码如下所示
RewriteCond %{HTTP_HOST} ^example-page.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.example-page.com
DirectoryIndex front_page.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule /about /about_page.php
redirect 301 /about https://www.new_domain_example.com/about
我遇到问题的地方是重定向位于 https://www.example-page.com.
的主页或目录索引我试过了
redirect 301 / https://www.example-page.com
还有
Redirect 301 http://www.example-page.com http://www.new_domain.com
第一个不起作用,因为该域的所有页面似乎都是不需要的。我只想将在 url 找到的 DirectoryIndex/ 主页重定向到新的 url.
第二次尝试也不行。在这一点上,我对我能做什么感到很困惑,我唯一想到的就是将主页外部化。这样看起来像。
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule /front /front_page.php
redirect 301 /front https://www.new_domain_example.com/front
我确定这不是必需的,我遗漏了一些东西。您将如何在不破坏我的其余代码的情况下重定向作为此代码中的目录索引的首页?
对于我做错了什么的任何帮助或见解将不胜感激。
如果您只想重定向主页,请尝试:
RewriteCond %{REQUEST_URI} ^\/.front_page\.php$
RewriteCond %{HTTP_HOST} !^newdomain\.com$
RewriteRule ^ https://newdomain.com%{REQUEST_URI} [R=301,L]
如果您想将旧域中的所有内容重定向到新域:
RewriteCond %{HTTP_HOST} !^newdomain\.com$
RewriteRule ^ https://newdomain.com%{REQUEST_URI} [R=301,L]