The Entrepreneur Forum | Startups | Entrepreneurship | Starting a Business | Motivation | Success

HELP! Any regular expression experts here?

Remove ads while supporting the Unscripted philosophy...become an INSIDER.

MJ DeMarco

Administrator
Staff member
EPIC CONTRIBUTOR
FASTLANE INSIDER
Read Millionaire Fastlane
I've Read UNSCRIPTED
Summit Attendee
Speedway Pass
Jul 23, 2007
31,408
117,600
3,751
Fountain Hills, AZ
Any reg-ex experts on the board? For the life of me, I can never figure out regular expressions. I'm having a URL redirect problem (for an Htaccess file) and was hoping to find a solution. I've spent a bunch of time on several websites trying to figure out the solution.

Reg-exs have always been like Japanese to me. I tried using this tool to no avail:

Free Online Regular Expression Tester - FreeFormatter.com

Basically I'm looking to solve a problem a described below...

301 Redirect

Code:
OLD PAGE
-------
https://www.thefastlaneforum.com/general-business-discussion/35110-golden-nuggets-tips-processes-how-tos.html

TO THIS NEW PAGE
-------
https://www.thefastlaneforum.com/community/threads/golden-nuggets-tips-processes-how-tos.35110/

Optimally, any link with "general-business-discussion" should redirect to "community/threads/[thread-title].[thread-number]

Looking for a "catch all" for the above, not just the one link redirected.

I know for a reg-ex expert this is easy-peezy like asking someone to translate English to Japanese. Probably is, I know no Japanese and after a few hours of trying to learn I'm no closer to the solution. I picked a bad day to have some caffeine.

Another tool that I found helpful but still haven't got to a solution...

Regex101 - online regex editor and debugger
 

Don't like ads? Remove them while supporting the forum. Subscribe.

  • Thread starter
  • Admin
  • #3

MJ DeMarco

Administrator
Staff member
EPIC CONTRIBUTOR
FASTLANE INSIDER
Read Millionaire Fastlane
I've Read UNSCRIPTED
Summit Attendee
Speedway Pass
Jul 23, 2007
31,408
117,600
3,751
Fountain Hills, AZ

ApparentHorizon

Platinum Contributor
Speedway Pass
Apr 1, 2016
945
2,783
653
Greenville, SC
Thank you but that really doesn't help me.

This seems to work in the RegEx101, now I got to translate it.

Code:
(general-business-discussion).(\d+)*.(.+)?(.html?)

AND

community/threads/$3.$2

Something closer to this... I haven't tested it

Code:
RewriteRule ^community/threads/([0-9a-zA-Z-]+).([0-9]+)/ /general-business-discussion/$1-$2.html
 
  • Thread starter
  • Admin
  • #5

MJ DeMarco

Administrator
Staff member
EPIC CONTRIBUTOR
FASTLANE INSIDER
Read Millionaire Fastlane
I've Read UNSCRIPTED
Summit Attendee
Speedway Pass
Jul 23, 2007
31,408
117,600
3,751
Fountain Hills, AZ
I think it needs to be the other way around? The url with "general-business-etc" should be the one redirecting.
 

scottmsul

Bronze Contributor
FASTLANE INSIDER
Read Millionaire Fastlane
I've Read UNSCRIPTED
Speedway Pass
Apr 29, 2017
132
370
190
29
Boulder, CO
There could be issues if someone creates a thread with "general-business-discussion" in the name. Maybe something like this?

Code:
^https://www.thefastlaneforum.com/general-business-discussion/(\d+)-(.+)(.html)?$

https://www.community/threads/$3.$2

More specific is generally better. ^ and $ are usually the start and end of a string but may depend on the language.
 
  • Thread starter
  • Admin
  • #7

MJ DeMarco

Administrator
Staff member
EPIC CONTRIBUTOR
FASTLANE INSIDER
Read Millionaire Fastlane
I've Read UNSCRIPTED
Summit Attendee
Speedway Pass
Jul 23, 2007
31,408
117,600
3,751
Fountain Hills, AZ
Something closer to this... I haven't tested it

Code:
RewriteRule ^community/threads/([0-9a-zA-Z-]+).([0-9]+)/ /general-business-discussion/$1-$2.html


There could be issues if someone creates a thread with "general-business-discussion" in the name. Maybe something like this?

Code:
^https://www.thefastlaneforum.com/general-business-discussion/(\d+)-(.+)(.html)?$

https://www.community/threads/$3.$2

More specific is generally better. ^ and $ are usually the start and end of a string but may depend on the language.

Thank you both, much appreciated.

Unfortunately neither work.

Can be tested here:
htaccess Tester - madewithlove

My iteration works, but it isn't working in the htaccess file.
 
  • Thread starter
  • Admin
  • #8

MJ DeMarco

Administrator
Staff member
EPIC CONTRIBUTOR
FASTLANE INSIDER
Read Millionaire Fastlane
I've Read UNSCRIPTED
Summit Attendee
Speedway Pass
Jul 23, 2007
31,408
117,600
3,751
Fountain Hills, AZ
My iteration works, but it isn't working in the htaccess file.

Got it to work finally, but as @scottmsul mentioned, it's a little sketchy.

Code:
RewriteRule .*(general-business-discussion).(\d+)*.(.+)?(.html?) /community/threads/$3.$2 [R=301,L]
 

Sponsored Offers

  • Sticky
MARKETPLACE You Are One Call Away From Living Your Dream Life - LightHouse’s Accountability Program ⚡
Thanks for clearing that up. What do you recommend for those who are still in the process of...
  • Sticky
MARKETPLACE Fox Web School "Legend" Group Coaching Program 2021
I thought I would post up the first video from the newest 2021 program content... Just a...
  • Sticky
MARKETPLACE Kill Bigger Incubator
I have not offered one of these in a while, but it looks like I have time to take on an...
  • Sticky
MARKETPLACE Lex DeVille's - Advanced Freelance Udemy Courses!
Hi Lex, I looked at several options including Kajabi and settled on the Divi theme on Wordpress...
  • Sticky
MARKETPLACE Grow Your Business With a Book (An Unorthodox Marketing Strategy That Built One of the Largest...
Are you looking for a new, lesser-known but potentially very lucrative source of leads to your...
  • Sticky
FEATURED! Introducing... WEALTH EXPO$ED, A Short Story By MJ DeMarco
The story is BASED UPON a true story. The details aren't entirely accurate or from a distinct...



Forum Sponsor

Grow an online business:
- Start immediately!
- Master business skills!
- 100+ Fastlane students enrolled!
Review & Details >

New Topics

Fastlane Insiders

View the forum AD FREE.
Private, unindexed content
Detailed process/execution threads
Monthly conference calls with doers
Ideas needing execution, more!

Join Fastlane Insiders.

Top Bottom