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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:04:31+00:00 2026-05-22T15:04:31+00:00

I want the htaccess Redirect 301 to do the following using regex: http://example.com/folder/abc_123_123.htm to

  • 0

I want the htaccess Redirect 301 to do the following using regex:

http://example.com/folder/abc_123_123.htm

to

http://example.com/abc-123-123.shtml

The 3 objectives of new URL are

  • delete /folder/

  • replace all _ with –

  • replace htm with shtml

  • 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-22T15:04:32+00:00Added an answer on May 22, 2026 at 3:04 pm

    Best I’m aware, your point #2 cannot be done without a RewriteMap, which requires some pesky configuration, or multiple rules.

    This implementation should be generic and work for any number of underscores, but it’s expensive in that it might trigger many redirect (in fact, potentially enough to fire redirect errors in browsers if you’ve tons of underscores in your paths):

    RewriteBase /
    RewriteRule ^(folder/[^_]*)_(.*\.html?)$ /$1-$2 [L,R=301]
    RewriteRule ^folder/(*+)\.html?$ /$1.shtml [L,R=301]
    

    Alternatives include enumerating use-cases as needed, or (better, I suspect) rewriting the request to a perl or php script and doing the regexp_replace + redirect 301 from there.

    RewriteBase /
    RewriteRule ^folder/(*+)\.html?$ /folder/redirect.php [L,QSA]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want the htaccess Redirect 301 to do the following: http://mysite.com/article.php?id=123 to http://mysite.com/123 Another
I want to redirect using .htaccess abc.com/test.php to abc.com/test . but it will execute/display
I want to redirect users trying to access http://example.com/car/ to http://example.com/car/blue/ in .htaccess I
I want to create URL re-write rules for following URL in htaccess. http://example.com/vedios/category/fun/ ->
I want to redirect adm folder to administrator my .htaccess code: Redirect 301 /adm
I'm attempting the following in an HTACCESS file: I want to 301 redirect this
I just want to get a quick htaccess redirection. ie: domain.com/subfolderGreen --> domain.com/index.php?folder=subfolderGreen (note
I'm trying to make the following redirection (301) using .htaccess *?page=1 redirects to *
I have a website with a for example ( http://example.com ). I want any
I want to redirect http://olddomain.com to http://newdomain.com for my all urls..keeping the page 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.