Solution 1 :

you can try this :

RewriteEngine On
RewriteCond %{HTTP_HOST} ^olddomain.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.olddomain.com$ [NC]
RewriteRule (.*)$ http://newdomain.com/$1 [R=301,L]

or also find various site for redirect using htaccess
hope this helps you

Problem :

I need help with htaccess rewrite module.

https://www.olddomain.co.za/somepath1 to http://subdomain.newdomain/somepath2/admin.php

I have tied:

    # Redirect Client Portal Page if IP match
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.olddomain.comsomepath1$
RewriteCond expr " -R '192.168.0.0/16'" [OR]
RewriteCond expr " -R '10.0.0.0/8'" [OR]
RewriteCond expr " -R '172.16.0.0/12'"
RewriteRule (.*) http://subdomain.newdomain.com/somepath2/admin.php/$1 [R=301,L]
</IfModule>

If %{REMOTE_ADDR} is found only in /somepath1 folder, redirect, otherwise show https://www.olddomain.co.za/somepath1.

I have spent a lot of time trying a few solutions but non prevailed.
Thanks

Comments

Comment posted by A.J. Hart

I apologize, was not quite clear on my question.

Comment posted by A.J. Hart

Unfortunately no dice:

Comment posted by shashikant kuswaha

try this RewriteEngine On RewriteCond %{REMOTE_ADDR} !^51.21.61 RewriteCond %{REMOTE_ADDR} !^131.221.61.91 RewriteCond %{REQUEST_URI} /reset-pageviews [NC] RewriteRule .* index.php [F,L]

Comment posted by A.J. Hart

Thanks for the reply. It’s redirecting everything to a broken page…No dice. I need to redirect if ip match and only when client request ….co.za/client-portal/index.php to new domain.