Romain
Romain

Reputation: 455

htaccess redirect specific page of specific domains to specific pages

I have created a new Wordpress site that will replace a multi-domain website. Server redirections has been done on different domains to point all of them to the same path.

I need do redirect pages based on the parent domain and also, redirect specific domain pages to new specific domain pages .

For example, when "www.mysite-example.com.au/contact" is requested it should redirect to "mysite.com.au/contact-us" and also "www.mysite-example.com.au/contact/form" should redirect to "mysite-example.com.au/request-contact-form"

Here is my current htaccess where I'm doing global redirection

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{HTTP_HOST} ^www.abilitypeople.com$ [NC]
RewriteRule ^(.*)$ http://abilitypeople.co.uk/ [R=301,L]

RewriteCond %{HTTP_HOST} ^www.abilitypeople.co.uk$ [NC]
RewriteRule ^(.*)$ http://abilitypeople.co.uk/ [R=301,L]

RewriteCond %{HTTP_HOST} ^www.abilitypeople.com.au$ [NC]
RewriteRule ^(.*)$ http://abilitypeople.com.au/ [R=301,L]


# 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]
</IfModule>

# END WordPress

Does any one know how to create these redirections on the same htacces

"www.mysite-example.com.au/contact" -> "mysite.com.au/contact-us"
"www.mysite-example.com.au/contact/form" -> "mysite-example.com.au/request-contact-form"

"www.mysite-example.co.uk/contact" -> "mysite.co.uk/contact-us"
"www.mysite-example.co.uk/contact/form" -> "mysite-example.co.uk/request-contact-form"

By the way, thanks to anubhava for his help

Upvotes: 2

Views: 541

Answers (1)

anubhava
anubhava

Reputation: 786349

You can have your rules like this:

Options +FollowSymLinks -MultiViews
RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?abilitypeople\.com$ [NC]
RewriteRule ^ http://abilitypeople.co.uk%{REQUEST_URI} [R=301,L,NE]

RewriteCond %{HTTP_HOST} ^www\.(abilitypeople\.(?:co\.uk|com\.au))$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L,NE]

RewriteRule ^contact/?$ contact.php [L,QSA]

Upvotes: 2

Related Questions