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 9187533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:47:34+00:00 2026-06-17T19:47:34+00:00

I have several different sets of variables that can be alhpa numeric. If I

  • 0

I have several different sets of variables that can be alhpa numeric.

If I comment out any two sets the other will work. Only one set will work but need all three to work.

First set is only one level:

domain.com/index.php?var1a=var1a

The second set can be one, two or three levels:

domain.com/index.php?var2a=var2a

domain.com/index.php?var2a=var2a&var2b=var2b

domain.com/index.php?var2a=var2a&var2b=var2b&var2c=var2c

The third set can be one, two or three levels:

domain.com/index.php?var3a=var3a

domain.com/index.php?var3a=var3a&var3b=var3b

domain.com/index.php?var3a=var3a&var3b=var3b&var3c=var3c

htaccess file looks like this:

RewriteEngine on
RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?var1a=$1 [L]
RewriteRule ^([a-zA-Z0-9_-]+)/$ index.php?var1a=$1 [L]

RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?var2a=$1 [L]
RewriteRule ^([a-zA-Z0-9_-]+)/$ index.php?var2a=$1 [L]
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$ index.php?var2a=$1&var2b=$2 [L]
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/$ index.php?var2a=$1&var2b=$2 [L]
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)([a-zA-Z0-9_-]+)/$ index.php?var2a=$1&var2b=$2&var2c=$3 [L]
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/$ index.php?var2a=$1&var2b=$2&var2c=$3 [L]

RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?var3a=$1 [L]
RewriteRule ^([a-zA-Z0-9_-]+)/$ index.php?var3a=$1 [L]
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$ index.php?var3a=$1&var3b=$2 [L]
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/$ index.php?var3a=$1&var3b=$2 [L]
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$ index.php?var3a=$1&var3b=$2&var3c=$3 [L]
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/$ index.php?var3a=$1&var3b=$2&var3c=$3 [L]

After testing I understand why this won’t work but cannot work out how to define the different sets.

  • 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-17T19:47:35+00:00Added an answer on June 17, 2026 at 7:47 pm

    Based on the comments, above, the search URLs are the easiest to accommodate since they start with a consistent /search, so that rule will go first:

    RewriteRule ^search/?$ index.php?search=true [L, NC]
    RewriteRule ^search/([a-zA-Z0-9_-]+)/?$ index.php?search=true&keyword=$1 [L, NC]
    RewriteRule ^search/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/?$ index.php?search=true&keyword=$1&keyword2=$2 [L, NC]
    

    /? makes the trailing slash optional so you can match with or without on the same rule.

    That leaves affiliate and post links. Assuming post links have a variety of starting terms (categories), unlike “search”, we need to distinguish those from usernames. Usernames only have one level, though, so first we can capture any two or three level URLs as post links:

    RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/?$ index.php?c=$1&m=$2 [L, NC]
    RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/?$ index.php?c=$1&m=$2&t=$3 [L, NC]
    

    Finally, for single level URLs to distinguish between categories and usernames, it’s probably the case that there are a limited number of known categories that change infrequently while usernames are more numerous and more prone to change. So, you need a lookup method for categories and then default any that don’t match to be usernames.

    To lookup categories, you need to use a RewriteMap. You’ll need to look through the RewriteMap documentation to determine which type will work best for your situation, but it would end up something like this:

    #Map is declared in virtual host context, not in .htaccess
    RewriteMap categorymap txt:/path/to/file/categories.txt
    
    RewriteCond ^([a-zA-Z0-9_-]+)/?$,${categorymap:$1} ^([^,]+),\1
    RewriteRule ^([a-zA-Z0-9_-]+)/?$ index.php?c=$1
    
    RewriteRule ^([a-zA-Z0-9_-]+)/?$ index.php?affiliate=$1
    

    I haven’t used RewriteMaps myself or RewriteConds of that particular format, so it may need tweaking, but the idea is that the RewriteCond says to match the incoming path against a capture of everything up to the comma (^([^,]+)) and then to match the categorymap against that captured pattern (\1).

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

Sidebar

Related Questions

In my game application I have several different activities that all can be accessed
I have a factory that processes a custom message format. Several different message sets,
we have model helper (used by several different models) called set_guids that sets self.theguid
I have several different numbers in a group that range in sizes and would
I have several different content type nodes (videos, image galleries, stories...) that I would
I have a page with several sets of radio buttons that are used to
I have several different processes within a single project that I work on. I
I have several Sets that store the objects of the same class, but I
I have a project where I need to give the users several different sets
I'm using jQuery to control an image gallery that will display any of several

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.