user1320260
user1320260

Reputation:

.htaccess Redirect rule to another domain

Currently I can rewrite a URL like this

RewriteRule ^pageOne$ /pageOne.php

I would like to do a Redirect to another domain not a rewrite to the current

So in the example below users who click on pageOne get redirected to the other URL

RewriteRule ^www.example.com/pageOne$ www.newexample.com/pageOne.php

EDITED

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

    RewriteCond %{HTTP_HOST} ^blog.example.co.uk$
    RewriteRule ^a-blog-post$ http://www.newexample.com/reviced-blog-post.html [L,R=301,NC]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /blog/index.php [L]
    </IfModule>
    # END WordPress

Upvotes: 2

Views: 130

Answers (1)

anubhava
anubhava

Reputation: 786021

That rule will be like this:

RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC]
RewriteRule ^pageOne/?$ http://www.newexample.com/pageOne.php [L,R=301,NC]

Upvotes: 2

Related Questions