Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8003907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:46:39+00:00 2026-06-04T16:46:39+00:00

I am trying to figure out how to rewrite URLs from something like this:

  • 0

I am trying to figure out how to rewrite URLs from something like this:
example.com/collection.php?collection=1

Into:
example.com/collection-name.php

I recently redesigned an e-commerce site and need to redirect the old URLs to the new ones. I’ve seen loads of instructions on how to use the value of collection=1 in a rewritten URL but not how to use text instead of the value. There are only 5 collection values that need to be redirected but in addition there are also old URLs that have multiple params in them that also need to be rewritten/redirected as text. I hop that made sense.

So I think I can get them all worked out if I can get the initial redirect set up.

Other/more complex old URLs look like this:
example.com/collection.php?collection=1&product=2&item=3

Which would then need to be redirected to:
example.com/collection-name/sub-collection-name/product-name.php

Not sure exactly how to go about doing this. I don’t want to write line after line in the .htaccess file but I have no idea of how else to accomplish this.

Thanks in advance, I appreciate andy and all help in this matter!

EDIT————————————
Here’s my new rewrite condition and rule based on the info provided to me. This would be the rule for the URLs containing all the query params using 3 separate RewriteMaps.

RewriteCond %{QUERY_STRING} collection=([^&]+)&product=([^&]+)&item=([^&]+)
RewriteRule collection.php shop/${categorymap:%1}/${rangemap:%2}/${productmap:%3}\.php [R=301,L]

Please let me know if anything looks off or I missed anything. Wasn;t sure if I needed to use $1, $2, $3 for each of the query params. I’m still a NOOB with rewrites. Thanks!

Edit——————————————————

Using the following code in my .htaccess file:

RewriteCond %{QUERY_STRING} collection=([^&]+)
RewriteRule collection.php shop/${categorymap:%1}\.php [R=301,L]

My URLs that start as “example.com/collection.php?collection=1

Are being rewritten as: example.com/shop/.php?collection=1

I am a bit lost on this one. Could it be that my Redirect Maps are not being read? Or is it something else? Thanks for the help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T16:46:40+00:00Added an answer on June 4, 2026 at 4:46 pm

    You want to look into using a RewriteMap. You can specify the maps you want for collection, sub-collection and products, and then look up the text for each number.

    So you would define a RewriteMap in your virtualhost config with something like

    RewriteMap categmap txt:/path/to/category/map.txt
    

    Then your rewrite rule would look something like

    RewriteCond %{QUERY_STRING} collection=([^&]+)
    RewriteRule collection.php ${categmap:%1} [L,R]
    

    Add more RewriteConds for your more complicated cases and make separate rules out of them. Place the more specific rules first in the file, then the more general ones.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to redirect URLs from example.net/customname or example.net/customname/ to example.net/my/home.php?username=customname . This in
trying to figure out how to rewrite this url clientside blog.com/post/how-to-get-the-ladies to point serverside
Trying to figure out how I can do this properly. The print_r looks like
I'm trying to figure out how to remove trailing slashes from only certain URLs
I'm trying to figure something out. This is the code I'm using to hide
Im trying to make my site URLS 'tidy' and can't figure out querystrings example,
trying to figure out why this is happening - I have an input text
Trying to figure out the best way to set up collection lists for users
I spend a lot of time trying to figure out what's wrong with this
OK, I have been trying to figure this out for a while. I just

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.