0

I just want 301 redirect rule for multiple query string to make it SEO friendly url.

Internal Url: www.example.com?p=54&p1=ABC XYZ&p2=XXX45767 and so on.

301 Redirect Url: www.example.com/54-ABC-XYZ-XXX45767?p=54&p1=ABC XYZ&p2=XXX45767

So, the redirect url must contain the old query parameters too.

1 Answer 1

2

First step is to check the QUERY_STRING for the parameters in question. If a match is found, then a redirect should occur.

You can use the following in your /.htaccess file:

RewriteEngine On

# Check the query string and capture parts
RewriteCond %{QUERY_STRING} ^p=([^&]+)&p1=([^&]+)&p2=([^&]+)$

# If at the root of the domain, redirect
RewriteRule ^$ /%1-%2-%3 [R=302,L]

To make the redirect permanent and cached by browsers and search engines, change 302 to 301.

Sign up to request clarification or add additional context in comments.

Comments

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.