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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:11:33+00:00 2026-05-20T12:11:33+00:00

a short question about optional regex : imagine a given page thats currently rewritten/beautified

  • 0

a short question about optional regex:

imagine a given page thats currently rewritten/beautified to:

/xx/somepage/description-description-description

while actually loading the ugly url below water:

/somepage?ln=xx

via this seemingly working rule:

RewriteRule ^([a-z][a-z])/(.*)/(.*?)$ /$2?ln=$1 [L]

However, currently the last portion /description is now compulsory. Without it error 404 occurs. What RewriteRule should I use to make the third and last part optional? Especially since it has no file-fetching meanings and is only for the user to make a url more descriptive.

In other words, I would like all three of the below to work the same way:

/xx/somepage
/xx/somepage/description-description-description

thanks very much

update

both of these seem to work fine:

RewriteRule ^([a-z][a-z])/(.*?)(/.*)?$   /$2?ln=$1 [L]
RewriteRule ^([a-z][a-z])/([^/]+)(/.*)?$ /$2?ln=$1 [L]

the difference being on the the middle part. I gather it has something to do with greedyness… but why/how they differ exactly… someone else might be able to shed light here.

  • 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-20T12:11:33+00:00Added an answer on May 20, 2026 at 12:11 pm

    Remove the final / in your rule, or place it in an optional group. As it stands, and from what I see, the description isn’t completely necessary, but a trailing slash is.

    New RegEx:

    RewriteRule ^([a-z][a-z])/(.*?)(/.*)?$ /$2?ln=$1 [L]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a short question that I've been wondering about for a while. There
Short question. How do you go about transposing UML diagrams into code? The class
Happy easters, everyone. I am currently learning topological sort and having a question about
I just have a short question about switching the color of sifr objects on
Just a very short question about DropBox - is there any way to find
I have a rather short question about anonymous event handlers: This is the code
Already i posted my earlier question about my FTP process (simple and short ),it
I have a short question about the std::set container. Right now I am feeding
a short question about indent style of checkbox. a new checkbox is created as
I have an ultra short question about R My aim is to assign a

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.