Cyberlicious
Cyberlicious

Reputation: 49

How to redirect domain path to other domain path using .htaccess?

The domains below are just sample domaains. I want to redirect mydomain.com/test/ (wildcard) to google.com/dl (wildcard)

I am using this codes

RewriteEngine on
RedirectMatch 301 ^/test/.*$ https://google.com/dl

But when i access https://example.com/test/hi it redirects to https://google.com/dl , instead of https://google.com/dl/hi

How can I do it? Thanks

Upvotes: 2

Views: 633

Answers (2)

Buddhiprakash Kumawat
Buddhiprakash Kumawat

Reputation: 47

You can try, you will find 100% solution, you must add below 3 lines to project's root folder .htaccess file

RewriteEngine on
RewriteBase /
RewriteRule (.*) http://www.new-domain.com/$1 [R=301,L][/php]

Upvotes: -1

RavinderSingh13
RavinderSingh13

Reputation: 133620

Could you please try following, written with shown samples. Please make sure to clear your browser cache before testing your URLs.

RewriteEngine on
RewriteRule ^test/(.*)/?$ https://google.com/dl/$1 [R=301,NC,L]

Upvotes: 2

Related Questions