Reputation: 170
I am trying to redirect and old domain(a.com) to the new domain (b.com) keeping the parameters in the url.
So if I go to: www.a.com/page/parameters should redirect to www.b.com/page/parameters
I've tried a bunch of options to no avail.
In all of them if I go to the domain itself (www.a.com) it succesfully redirects to the new one(www.b.com), but when I go to a specific page(www.a.com/page) the old domain stays in place in this case showing a 404 page.
These are the solutions I've already tried:
Option 1
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?exampleold\.ie$
RewriteRule (.*)$ http://www.examplenew.com/$1 [R=301,L]
</IfModule>
Option 2
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^exampleold\.ie$ [NC]
RewriteRule ^(.*)$ http://www.examplenew.com/$1 [R=301,L]
</IfModule>
Option 3
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^exampleold.ie
RewriteRule ^(.*) http://www.examplenew.com/$1 [P]
</IfModule>
Option 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>
The website is made in Wordpress
This is the full .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
Upvotes: 1
Views: 1323
Reputation: 785481
Don't mix mod_alias
rules with mod_rewrite
rules and keep redirect rules before WP rules.
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
I have made some other improvements in your htaccess
.
Upvotes: 1