Natalia
Natalia

Reputation: 1027

Redirect url with language variable to different url htaccess

I need to make the following redirection using htaccess (WordPress)

http://oldweb.com/pl/

to https://newweb.com/url/differenturl/

But this redirection should work only for http://oldweb.com/pl/, the urls http://oldweb.com/en/ or http://oldweb.com/il/ should not have any redirection.

My solution works but it works for /en/ and /il/ also:

Redirect 301 http://oldweb.com/pl/ https://newweb.com/url/differenturl/

I'm not a hero in rewriting, sorry :) Can anyone help me with this simple thing?

Upvotes: 1

Views: 33

Answers (1)

anubhava
anubhava

Reputation: 784968

Redirect matches only REQUEST_URI not full URL with domain protocol etc.

Better to use a RewriteRule just below RewriteEngine On line in your root .htaccess:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(?:www\.)?oldweb\.com$ [NC]
RewriteRule ^pl/?$ https://newweb.com/url/differenturl/ [L,NC,R=301]

Upvotes: 1

Related Questions