2

Sorry, but I couldn't find any help for my problem. Hoping you guys can help.

I have the url: http://example.com/many-pages?lang=xx

I would like to turn that into just: http://example.com/many-pages

Stripping away the "?lang=xx" where "xx" is the language code. Also make it a 301 redirect.

0

1 Answer 1

2

Put this code in your DOCUMENT_ROOT/.htaccess file:

RewriteEngine On

RewriteCond %{THE_REQUEST} \s/+([^?]*)\?lang=[^\s&]+ [NC]
RewriteRule ^ /%1? [R=301,NE,L]
Sign up to request clarification or add additional context in comments.

3 Comments

It worked pretty well in my test. What is location of your .htaccess and are there more rules there? Make sure this is first rule in your .htaccess
I had moved it up to over my custom rules and it hadn't worked. Then I raised it to above WordPress rules and it's working. Do you think that might conflict with WordPress rules?
No it won't conflict with WP rules.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.