Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex 如何在.htaccess中从一个子域重定向到另一个子域?_Regex_Apache_.htaccess_Mod Rewrite_Redirect - Fatal编程技术网

Regex 如何在.htaccess中从一个子域重定向到另一个子域?

Regex 如何在.htaccess中从一个子域重定向到另一个子域?,regex,apache,.htaccess,mod-rewrite,redirect,Regex,Apache,.htaccess,Mod Rewrite,Redirect,最近我们更改了子域的名称,现在我们需要将所有旧页面重定向到新子域页面 示例页面链接: 旧网址: 新网址: 我的发现:当我尝试在顶层访问子域时,它运行良好 如何将旧子域上的所有URL重定向到新子域 目前我在.htaccess文件中有以下代码,请指导解决问题 RewriteEngine on RewriteCond %{HTTP_HOST} ^jquery\.webcodehelpers\.com$ [OR] RewriteCond %{HTTP_HOST} ^www\.jquery\.webc

最近我们更改了子域的名称,现在我们需要将所有旧页面重定向到新子域页面

示例页面链接:

  • 旧网址:

  • 新网址:

我的发现:当我尝试在顶层访问子域时,它运行良好

如何将旧子域上的所有URL重定向到新子域

目前我在.htaccess文件中有以下代码,请指导解决问题

RewriteEngine on
RewriteCond %{HTTP_HOST} ^jquery\.webcodehelpers\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.jquery\.webcodehelpers\.com$
RewriteRule ^/?$ "http\:\/\/uieiq\.webcodehelpers\.com\/search\/label\/jquery\ interview\ questions" [R=301,L]

通过
httpd.conf
启用
mod_rewrite
.htaccess
,然后将此代码放入
文档根目录下.htaccess
文件:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^jquery\.webcodehelpers\.com$ [NC]
RewriteRule ^ http://uieiq.webcodehelpers.com%{REQUEST_URI} [L,R=301,NE]

请阅读:这对我有效,并维护URI:

RewriteCond %{HTTP_HOST} ^jquery\.webcodehelpers\.com
RewriteRule (.*)$ http://uieiq.webcodehelpers.com/$1 [R=301,L]

我用它将一个子域重定向到另一个子域。

你好,我添加了anubhava,但它仍然不起作用,在.htaccess文件#-FrontPage-IndexIgnore.htaccess/?~*#中编码*/HEADER/README/_vtirewriteengine On RewriteCond%{HTTP_HOST}^jquery\.webcodehelopers\.com$[NC]RewriteRule^{REQUEST_URI}[L,R=301,NE]订单拒绝,允许从所有订单拒绝,允许从所有订单拒绝,允许拒绝来自所有AuthName webcodehelpers.com AuthUserFile/home/webcodeh/public_html/_vti_pvt/service.pwd AuthGroupFile/home/webcodeh/public_html/_vti_pvt/service.grp请不要在注释中发布代码,它根本不可读。编辑您的问题并在那里发布代码。还要确保jquery.webcodehelopers.com hosthey anubhava的文档_ROOT/.htaccess文件中包含上述代码。我在问题中添加了我的htaccess文件代码,请帮助我如何修改我无法按照另一篇文章中的建议使用%{REQUEST_URI}。