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

  • SEARCH
  • Home
  • 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 8825377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:51:47+00:00 2026-06-14T06:51:47+00:00

How to change: domain.com/go/?custom_ref=001 into domain.com/go/?ref=001 using htaccess rewrite please?

  • 0

How to change:

domain.com/go/?custom_ref=001

into

domain.com/go/?ref=001

using htaccess rewrite please?

  • 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-14T06:51:48+00:00Added an answer on June 14, 2026 at 6:51 am

    Not particularly flexible, but this works for your exact problem:

    RewriteEngine On
    RewriteCond %{QUERY_STRING} ^ref=([0-9]*)
    RewriteRule ^go/$ go/?custom_ref=%1 [QSA]
    

    Note that for the condition to match, ref must come first in the query string. The [QSA] (Query String Append) flag on the rule will retain the original query string, so other values passed will not be lost.

    Also note that this code assumes the .htaccess file is in the document root. If the file is elsewhere, you will need to adjust the RewriteRule. For example, changing it to the following will work when the .htaccess file is placed at /go/.htaccess:

    RewriteRule . ?custom_ref=%1 [QSA]
    

    If you want this to be more flexible, check out the responses to this question – they contain the syntax for changing a single variable in the query string and retaining everything else.


    Edit:

    To replace custom_ref with ref in the query string, you could use the following to redirect requests containing the custom_ref variable. Add this between RewriteEngine On and the other rules:

    RewriteCond %{QUERY_STRING} ^(([^&]*&)*)custom_ref=(.*)
    RewriteRule ^go/$ /go/?%1ref=%3 [R=301,L]
    

    This is more of a patch than a solution. If you have access to the code, I recommend fixing the variable names there instead.

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

Sidebar

Related Questions

I have problem with my .htaccess redirections. Say I want to change http://www.domain.com/login.php into
I have a subdomain setup as onlinedev.domain.com I need to use htaccess to rewrite
Has anyone tried before using subdomain-fu to change domain.com/user/1 to domain.com/UserName ? Are there
Short version: I need mysql code that will change [href=http://a-random-domain.com]hyperlink[/href] into <a href=http://a-random-domain.com>hyperlink</a> without
How do I change the following client-side URL domain.com/profile/jung domain.com/jung (preferable) to a server-side
I want to change from this address: www.domain.com/game.php?id=1 to somthing like that: www.domain.com/game/1/THE-NAME-OF-THE-GAME-IN-DB How
I'm trying to make a general rewrite rule to redirect all domain.com requests to
If I have a sitemap_index.xml : http://www.domain.com/sitemap.xml 2010-09-28 And I change the content or
I would like to re-write a URL similar to domain.com/products.aspx?product=20 into something like domain.com/products/20
I have the following url. http://domain.com/userfiles/dynamic/images/whatever_dollar_1318105152.png Everything in the url can change except the

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.