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 have the following in a .htaccess file redirect 301 /page.php http://domain.com/page Which works
I want to redirect to http referer page using mod rewrite htaccess. For example,
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 301 redirect from: www.olddomain.com to the root of newdomain.com but I
I want to redirect all my pages from example.com/video_player/vidinfo/456/game/halo-reach-coop-walkthrough-gameplay-in-hd/vtype/sd/ to example.com/video_player/vidinfo/456/game/halo-reach-coop-walkthrough-gameplay-in-hd/ using 301 redirects
I have a problem where I want to redirect all traffic [301 permanent] from
I want my htaccess to redirect URL that end on .html to the index.php,
How do I redirect this: www.sub.example.com to this: www.example2.com How is this done --
I'd like to redirect: http://site.com/FOO/BAR/BAZ to http://site.com/FOO/NEW/BAZ so, subsitute the second segment in my

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.