user3214892
user3214892

Reputation: 147

htaccess external domain to new domain

I have asked my domain host provider to point a website to my public_html folder. but now I have been told the if I need this other domain to redirect to a particular url on my primary domain website, I would need to do it in the htaccess file. At the moment I have researched and this is what my htaccess looks like without any luck!

# Switch rewrite engine off in case this was installed under HostPay.
RewriteEngine Off

SetEnv DEFAULT_PHP_VERSION 5

DirectoryIndex index.cgi index.php

# 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

RewriteCond %{HTTP_HOST} ^otherdomain.org.uk
RewriteRule ^(.*)$ http://www.primarydomain.org/blog/$1 [R=permanent,L]

The above does not redirect my otherdomain.org.uk to the blog page on my primarydomain.org/blog. Please note that my primarydomain.org/blog is a wordpress website page.

Upvotes: 0

Views: 128

Answers (1)

anubhava
anubhava

Reputation: 785266

Keep redirect rules before your WP rules.

Have your rules like this:

# Switch rewrite engine off in case this was installed under HostPay.
RewriteEngine Off

SetEnv DEFAULT_PHP_VERSION 5

DirectoryIndex index.cgi index.php

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^otherdomain.org.uk
RewriteRule ^(.*)$ http://www.primarydomain.org/blog/$1 [R=permanent,L]

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

# END WordPress

Upvotes: 1

Related Questions