0

I have some sample URLs I need rewritten:

RewriteCond %{QUERY_STRING} ^blue-spares-cycle-for-cancer-research$ [NC]
RewriteRule ^news/news-item/?$ http://www.blue-group.com/en/news/ [R=301,L]

RewriteCond %{QUERY_STRING} ^blue-spares-appoints-stuart-truckel-as-sales-director$ [NC]
RewriteRule ^news/news-item/?$ http://www.blue-group.com/en/news/ [R=301,L]

RewriteCond %{QUERY_STRING} ^project-manager-blue-machinery-london-ltd$ [NC]
RewriteRule ^about-us/careers/careers-item/$ http://www.blue-group.com/en/about/careers/ [R=301,L]

RewriteCond %{QUERY_STRING} ^000841:bakers-star-screen$ [NC]
RewriteRule ^used-machinery/en/screeners/used-machinery-item http://www.blue-group.com/en/used-machinery/ [R=301,L]

RewriteCond %{QUERY_STRING} ^000751:baler$ [NC]
RewriteRule ^used-machinery/en/other/used-machinery-item http://www.blue-group.com/en/used-machinery/ [R=301,L]

RewriteRule ^(.*)$ index.php/$1 [L]

My problem is I’ve got numerous similar URLs. Do I need to keep creating new RewriteCond for each one?

Also the results I’m getting are this for example:

http://www.blue-group.com/en/used-machinery/?000751:baler
1
  • 1
    If you are asking about consolidation (not just about QSA), then look into a RewriteMap. Commented Jun 11, 2014 at 15:17

1 Answer 1

1

Quick google search turned up this:

Keep original query (default behavior)

RewriteRule ^page\.php$ /target.php [L]
# from http://example.com/page.php?foo=bar
# to   http://example.com/target.php?foo=bar

Discard original query (notice the ? after target)

RewriteRule ^page\.php$ /target.php? [L]
# from http://example.com/page.php?foo=bar
# to   http://example.com/target.php

Replace original query

RewriteRule ^page\.php$ /target.php?bar=baz [L]
# from http://example.com/page.php?foo=bar
# to   http://example.com/target.php?bar=baz

Append new query to original query (QSA is key here)

RewriteRule ^page\.php$ /target.php?bar=baz [QSA,L]
# from http://example.com/page.php?foo=bar
# to   http://example.com/target.php?foo=bar&bar=baz

Original from here

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.