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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:43:59+00:00 2026-05-26T06:43:59+00:00

Not necessarily a problem, just something that I am not yet knowledgeable enough to

  • 0

Not necessarily a problem, just something that I am not yet knowledgeable enough to do. I have an .htaccess file that I am using for url rewriting. This is what I have now.

ErrorDocument 404 /inc/error_documents/404.php
ErrorDocument 503 /inc/error_documents/503.php

# For security reasons, Option followsymlinks cannot be overridden.
#Options +FollowSymLinks
Options +SymLinksIfOwnerMatch
RewriteEngine ON

RewriteRule ^home$ /index.php [nc]
RewriteRule ^(about|contact|giving-tree)/?$ /$1.php [nc]

RewriteRule ^giving-tree/([0-9+]?)/?$ giving-tree.php?ageBegin=$1 [nc]
RewriteRule ^giving-tree/([0-9+]?)/([0-9+]?)/?$ giving-tree.php?ageBegin=$1&ageEnd=$2 [nc]
RewriteRule ^giving-tree/([0-9+]?)/([0-9+]?)/([0-9+]?)/?$ giving-tree.php?ageBegin=$1&ageEnd=$2&page=$3 [nc]

What I want to be able to do is make some of the parts in the 3 bottom rules optional. I know that I can accomplish this with RewriteCond, but I’m not sure how. What I need is basically this:

RewriteCond %{HTTP_HOST} ^hearttohandparadise.org/giving-tree
RewriteRule /beginAge-([0-9+]) #make it send GET request with beginAge as the variable
RewriteRule /endAge-([0-9+]) \?beginAge=$1 #make it send GET request with endAge as the variable

etc… etc…

Is there any way to accomplish this just by relying on .htaccess? or am I just fantasizing?

Forgive me is I sound stupid.

  • 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-05-26T06:44:00+00:00Added an answer on May 26, 2026 at 6:44 am

    No, it’s a perfectly valid idea. You’d basically want to allow the user to write the URI in an unstructured manner, without a strict order imposed, right? Like, I could write giving-tree/page-6/endAge-23?

    If so, this is what you’re looking for:

    RewriteRule /beginAge-([0-9]+) giving-tree.php?beginAge=$1 [QSA,NC]
    RewriteRule /endAge-([0-9]+) giving-tree.php?endAge=$1 [NC,QSA]
    RewriteRule /page-([0-9]+) giving-tree.php?page=$1 [NC,QSA]
    

    You see, if any part of the URI matches the expression “/beginAge-([0-9]+)”, it’ll be redirected to giving-tree.php?beginAge=$1; the magic is done by the QSA, Query String Append, option, which, well, appends any existing query string to the resulting URI. So as more and more matches are found and more and more GET parameters added, the query string just grows.

    If you want a stricter thing, where some parameters are optional, but their order is fixed, then it’s uglier by magnitudes:

    RewriteRule /(beginAge-)?([0-9]+)/?(endAge-)?([0-9]+)?/?(page-)?([0-9]+)? giving-tree.php?beginAge=$2&endAge=$4&page=$6 [NC]
    

    I just made everything optional by using the ? operator. This one may use some prettifying/restructuring.

    (Alternatively, you could just do this:

     RewriteRule ^giving-tree/([^/]+)/?$ process.php?params=$1 [nc]
    

    That is, grabbing the entire part of the URI after the giving-tree part, lumping the whole thing into a single parameter, then processing the thing with PHP (as it’s somewhat better equipped to string manipulation). But the first version is certainly more elegant.)

    By the way, are you sure about the ([0-9+]?) parts? This means “One or no single character, which may be a digit or the plus sign”. I think you meant ([0-9]+), i.e. “one or more digit”.

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

Sidebar

Related Questions

I'd like to have a commit message cleanup that will not necessarily remove lines
Hopefully (but not necessarily) one that is independent of language or framework?
I know that being open source does not necessarily makes a program more/less secure
I have a need to convert images from CMYK to RGB - not necessarily
I had someone mention to me that catching all exceptions is not necessarily good
Is there something wrong with the .dll file? Shouldn't it just consider the code
Update: This may be something that just isn't doable. See this TLDR: How do
The people writing the user manual are not necessarily programmers, and they need a
There is a directed graph (not necessarily connected) of which one or more nodes
I am very new to C++ and I realise the following is not necessarily

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.