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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T13:16:47+00:00 2026-06-02T13:16:47+00:00

I’m not too good with mod_rewrite or regular expressions, but I need to ultimately

  • 0

I’m not too good with mod_rewrite or regular expressions, but I need to ultimately use 301 redirects for a site I am moving. The structure of the old site is as so

http://www.mywebsite.com/FF_Supersneaker_Black_Metallica_p/155-157.htm

and the new site for the same product is as so

https://www.mywebsite.com/FF_Supersneaker_Black_Metallica_p.html

What I need to do is extract and remove the “/155-157” and change the extension to .html instead of .htm

So Logically I guess I would need to find the last occurrence of a “/” and the last occurrence of a “.” and change the value of everything in between to “”. then the changing of the file extension is everywhere on the internet, but I don’t know how I would incorporate it with the rest of it.

edit:
Here is my .htaccess file:

<IfModule mod_rewrite.c>  
RewriteEngine On    
RewriteRule /(.*)/(.*)/[^/]*.htm$ /$1$2.html
</IfModule>

And here is the associated entry in my rewritelog when I tried to use it. (I just changed the ip and domain names. I used tail and copied the entry that popped up when I tried going to the page.

255.255.255.255 - - [25/Apr/2012:11:57:24 --0400] [www.mywebsite.com/sid#9b25ed8][rid#9e3cc48/initial] (1) [perdir /var/www/test/] pass through /var/www/test/FF_Supersneaker_Black_Metallica_p/155-157.htm

I added the extra /(.*) because there is an extra directory on my test page. The structure for that is
http://www.mywebsite.com/test/FF_Supersneaker_Black_Metallica_p/155-157.htm
to redirect to
http://www.mywebsite.com/test/FF_Supersneaker_Black_Metallica_p.html

Sorry for asking so many questions, also you can only enable rewrite logs buy going into the apache.conf or httpd.conf files and restarting the server, right? If that is the case then I don’t have the permissions.

  • 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-06-02T13:16:48+00:00Added an answer on June 2, 2026 at 1:16 pm

    All you’re doing here is stripping off the last path component and then adding “.html”. So maybe something like this:

    RewriteRule /(.*)/[^/]*.htm$ /$1.html
    

    The sequence [^/] means “any character not a /“, and * means “the previous pattern 0 or more times”, so [^/]*.htm matches any string of non-/ characters followed by .htm at the end of a string. We discard these, use everything else, and add .html.

    The URL Rewriting Guide has lots of information and examples.

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

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I need a function that will clean a strings' special characters. I do NOT
I need to clean up various Word 'smart' characters in user input, including but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want to count how many characters a certain string has in PHP, but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I want use html5's new tag to play a wav file (currently only supported
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.