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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:51:56+00:00 2026-05-30T13:51:56+00:00

I use url rewriting on my site and have implemented code: r = new

  • 0

I use url rewriting on my site and have implemented code:

        r = new Regex(@"Default.aspx\?Buy=(?<1>[\w\-\+]*)(?:&amp;|&)+PageIndex=(?<2>[\d]*)""", RegexOptions.IgnoreCase);
        txt = r.Replace(txt, "$1_dp.html?page=$2\""); 

In that case my links are:

http://www.mydomain.com/computers_dp.html?page=0 [1,2,3] depends on page number.

Is it simple way by RegEx to check if page = 0 then don’t add param ?page=0 and add it only if PageIndex is > 0.

Thanks!

  • 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-30T13:51:57+00:00Added an answer on May 30, 2026 at 1:51 pm

    Okay, I think this is the easiest way to solve this. Assuming the regex you have already implemented works, I would add another regex to simply replace "?page=0" with "".

    r2 = new Regex(@"\?page=0$""", RegexOptions.IgnoreCase);
    txt = r2.Replace(txt, "\""); 
    

    There’s really no way to check the value of captured groups within a regex, aside from really painful conditional lookaheads, so just adding another regex to cut out the corner case is the simplest, and therefore best solution.

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

Sidebar

Related Questions

I use url rewriting on my site (ASP.NET 4.0 / IIS6), instead of aspx
I want to use in-build URL rewriting provided by ASP.NET 4.0. I have tried
I have the following site layout. Main page is being loaded using url rewriting
I'm sitting here trying to find a way around URL-rewriting for my new site.
I use url rewriting and one of my urls is /blah/file ILLEGAL CHARS.jpg ILLEGAL
In URL rewriting, i am quite confused that should i use underscore (_) OR
You can use the URL helper in Code Igniter to load CSS and Javascript
We have a web application where we are using global.asax for url rewriting. We
My site currently handles URL's like this... /?p=home /?p=profile&userid=1 /?p=users.online /?p=users.online&page=23 /?p=mail.inbox /?p=mail.inbox&page=12 ...
We want to redirect all request in an ASP.NET site to ~/Default.aspx to close

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.