重定向域,使用.htaccess保留参数

重定向域,使用.htaccess保留参数,.htaccess,.htaccess,我正在尝试将旧域(a.com)重定向到新域(b.com),并将参数保留在url中 因此,如果我去: www.a.com/page/parameters 应该重定向到 www.b.com/page/parameters 我尝试了很多选择,但都没有用 在所有这些情况下,如果我转到域本身(www.a.com),它会成功地重定向到新域(www.b.com),但当我转到特定页面(www.a.com/page)时,旧域将保持不变,在本例中显示404页面 以下是我已经尝试过的解决方案: 选择1 <IfM

我正在尝试将旧域(a.com)重定向到新域(b.com),并将参数保留在url中

因此,如果我去: www.a.com/page/parameters 应该重定向到 www.b.com/page/parameters

我尝试了很多选择,但都没有用

在所有这些情况下,如果我转到域本身(www.a.com),它会成功地重定向到新域(www.b.com),但当我转到特定页面(www.a.com/page)时,旧域将保持不变,在本例中显示404页面

以下是我已经尝试过的解决方案:

选择1

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?exampleold\.ie$ 
RewriteRule (.*)$ http://www.examplenew.com/$1 [R=301,L]
</IfModule>

重新启动发动机
重写cond%{HTTP_HOST}^(www\)?示例旧版\.ie$
重写规则(.*)$http://www.examplenew.com/$1[R=301,L]
选择2

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^exampleold\.ie$ [NC]
RewriteRule ^(.*)$ http://www.examplenew.com/$1 [R=301,L]   
</IfModule>

重新启动发动机
RewriteCond%{HTTP_HOST}^exampleold\.ie$[NC]
重写规则^(.*)$http://www.examplenew.com/$1[R=301,L]
选择3

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^exampleold.ie
RewriteRule ^(.*) http://www.examplenew.com/$1 [P] 
</IfModule>

重新启动发动机
RewriteCond%{HTTP_HOST}^示例old.ie
重写规则^(.*)http://www.examplenew.com/$1[P]
选择4

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www\.)?exampleold\.ie$ [NC]
RewriteRule ^ http://www.examplenew.com%{REQUEST_URI} [R=301,L]
</IfModule>

重新启动发动机
重写基/
重写cond%{HTTP_HOST}^(www\)?示例旧版\.ie$[NC]
重写规则^http://www.examplenew.com%{REQUEST_URI}[R=301,L]
这个网站是用Wordpress制作的

这是完整的.htaccess

suPHP_ConfigPath /var/sites/b/examplenew.com/public_html
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

Redirect 301 /testimonial/ab-jan13/ http://www.examplenew.com/
Redirect 301 /homepage_slide/gopro-hero4/ http://www.examplenew.com/
Redirect 301 /product/gopro-hero3-black-edition-surf/ http://www.examplenew.com/
Redirect 301 /contactus.php http://www.examplenew.com/
Redirect 301 /news/mundaka/487 http://www.examplenew.com/blog/


RewriteCond %{HTTP_HOST} ^(www\.)?example1old\.ie$ [OR]
RewriteCond %{HTTP_HOST} ^www.example1old.ie$ [OR]
RewriteCond %{HTTP_HOST} ^(www\.)?example2old\.ie$ [OR]
RewriteCond %{HTTP_HOST} ^www.example2old.ie$
RewriteRule (.*)$ http://www.examplenew.com/$1 [R=301,L]

</IfModule>

# END WordPress
#Gzip 

<ifmodule mod_deflate.c>

AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript text/javascript

</ifmodule> 

#End Gzip
suPHP\u ConfigPath/var/sites/b/examplenew.com/public\u html
#开始WordPress
重新启动发动机
重写基/
重写规则^index\.php$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/index.php[L]
重定向301/推荐信/ab-jan13/http://www.examplenew.com/
重定向301/主页\幻灯片/gopro-hero4/http://www.examplenew.com/
重定向301/product/gopro-hero3-black-edition-surf/http://www.examplenew.com/
重定向301/contactus.phphttp://www.examplenew.com/
重定向301/news/mundaka/487http://www.examplenew.com/blog/
重写cond%{HTTP_HOST}^(www\)?示例1old\.ie$[或]
RewriteCond%{HTTP_HOST}^www.example1old.ie$[或]
重写cond%{HTTP_HOST}^(www\)?示例2old\.ie$[或]
重写cond%{HTTP_HOST}^www.example2old.ie$
重写规则(.*)$http://www.examplenew.com/$1[R=301,L]
#结束WordPress
#Gzip
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css应用程序/x-javascript应用程序/javascript text/javascript
#结束Gzip

不要将
mod\u alias
规则与
mod\u rewrite
规则混用,并将重定向规则放在WP规则之前

suPHP_ConfigPath /var/sites/b/examplenew.com/public_html
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteRule ^(testimonial/ab-jan13/|homepage_slide/gopro-hero4/|product/gopro-hero3-black-edition-surf/|contactus\.php|news/mundaka/487) http://www.examplenew.com/ [L,NC,R=302]

RewriteCond %{HTTP_HOST} ^(www\.)?example1old\.ie$ [NC,OR]
RewriteCond %{HTTP_HOST} ^(www\.)?example2old\.ie$ [NC]
RewriteRule ^ http://www.examplenew.com%{REQUEST_URI} [R=301,L]

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

</IfModule>

# END WordPress
#Gzip 

<ifmodule mod_deflate.c>

AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript text/javascript

</ifmodule>     
#End Gzip
suPHP\u ConfigPath/var/sites/b/examplenew.com/public\u html
#开始WordPress
重新启动发动机
重写基/
重写规则^(推荐信/ab-jan13/|主页|幻灯片/gopro-hero4/|产品/gopro-hero3-black-edition-surf/| contactus\.php |新闻/mundaka/487)http://www.examplenew.com/ [L,NC,R=302]
重写cond%{HTTP_HOST}^(www\)?示例1old\.ie$[NC,或]
重写cond%{HTTP_HOST}^(www\)?示例2old\.ie$[NC]
重写规则^http://www.examplenew.com%{REQUEST_URI}[R=301,L]
重写规则^index\.php$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/index.php[L]
#结束WordPress
#Gzip
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css应用程序/x-javascript应用程序/javascript text/javascript
#结束Gzip

我对您的
htaccess

做了一些其他改进。您能显示您当前的.htaccess吗?添加了完整的htaccess-anubhava