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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T12:21:44+00:00 2026-05-16T12:21:44+00:00

I am trying to combine these four get variables (sch, val, lmt, ord) into

  • 0

I am trying to combine these four get variables (sch, val, lmt, ord) into a nice looking url re_write. Currently I have the following in my .htaccess file and it works if all variables are included, however, if I only input the first two variables (sch & val) it breaks:

RewriteRule ^search/([^/]*)/([^/]*)/([^/]*)/([^/]*)$ 
             search.php?sch=$1&val=$2&lmt=$3&ord=$4 [L]

http://www.domain.com/search/City/London/5/asc works
http://www.domain.com/search/City/London but this doesn’t

  • 1 1 Answer
  • 1 View
  • 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-05-16T12:21:45+00:00Added an answer on May 16, 2026 at 12:21 pm

    Why not just add the other rewrite rules ahead of it. IE:

     RewriteRule ^search/([^/]*)$ 
             search.php?sch=$1 [L]
     RewriteRule ^search/([^/]*)/([^/]*)$ 
             search.php?sch=$1&val=$2 [L]
     RewriteRule ^search/([^/]*)/([^/]*)/([0-9]*)$ 
             search.php?sch=$1&val=$2&lmt=$3 [L]
     RewriteRule ^search/([^/]*)/([^/]*)/([0-9]*)/([^/]*)$ 
             search.php?sch=$1&val=$2&lmt=$3&ord=$4 [L]
    

    That should work. Not sure if it is what you want, but I do not really think it is “possible” to do that without just doing a query and passing the full query string as one line then parsing it PHP side.

    EDIT

    The nice thing about doing all this in .htaccess vs PHP is it requires less logic and you pass what you want to your script in the correct values. My preference would be using the .htaccess above.

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

Sidebar

Related Questions

I'm trying to combine these variables and append them to a select tag but
Can I combine these 2 SQL statements? Currently running 2 queries. Trying to tighten
im trying to combine two images into a single image. unfortunately this has to
I'm trying to combine multiple column values into 1 and then label them distinctly
I'm trying to combine 4 input fields into a jQuery function so that it
I'm trying to combine multiple files in multiple input directories into a single file,
I am trying to combine these 2 queries in such a way to determine
I'm trying to combine the following three media queries into one: @media only screen
I'm trying to combine multiple, smaller XML files into one large XML. I have
trying to save a step and combine these two queries but not sure how

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.