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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T15:09:37+00:00 2026-05-15T15:09:37+00:00

I need to have a RegEx that will match a URI like this based

  • 0

I need to have a RegEx that will match a URI like this based on the subdomain “blog”–

http://blog.foo.com/2010/06/25/city-tax-sale/

and redirect like this (getting rid of the subdomain and numbers/date)–

http://foo.com/city-tax-sale/

where the last bit “city-tax-sale” would be a wildcard. So basically any incoming URI that starts with ‘blog.foo.com’ would be redirected to ‘foo.com’ + ‘whatever is at the end of the above URI after the three sub paths with numbers.

I hope that makes sense. Just trying to create one redirect instead of writing every single one.

  • 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-15T15:09:38+00:00Added an answer on May 15, 2026 at 3:09 pm

    This will explicitly match your date format, rather than any series of digits and slashes:

    RewriteCond %{HTTP_HOST} ^blog\.foo\.com$ [NC]
    RewriteRule ^/\d{4}/\d{2}/\d{2}/(.*)$ http://foo.com/$1 [L,R=301]
    

    The regex part can be broken does to:

    ^      # start of non-domain url
    /\d{4} # slash followed by 4 digits
    /\d{2} # slash followed by 2 digits
    /\d{2} # slash followed by 2 digits
    /      # closing slash
    (.*)   # rest of the url, captured to group 1
    $      # end of url
    

    With the $1 in the replacement being group 1.

    In the options part:
    L is for “Last” – tells it to not bother looking at other rules.
    R=301 is for Redirect with 301 header, which means permanent redirect (just R would send a temporary 302 header)

    The RewriteCond bit performs a case-insensitive (NC option) check on the HTTP_HOST header (supplied by user/client) and if it starts blog.foo.com it performs the rewrite, otherwise it doesn’t.

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

Sidebar

Related Questions

I need a Regex that will match a java method declaration. I have come
I have a regex call that I need help with. I haven't posted my
I have an ASP website which I need to add a RegEx match to.
I have a regex that I thought was working correctly until now. I need
Does VbScript have a native implementation for Regex? I need to validate e-mail addresses
I have problem need to solved with Regex If i am using Firefox or
I need to match html tags(the whole tag), based on the tag name. For
I know that I can use regex to match substrings in a string, but
I have a regexp I'm using with sed, but now I need to make
We have need for a rating system in a project we are working on,

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.