The Entrepreneur Forum | Financial Freedom | Starting a Business | Motivation | Money | Success

The Entrepreneur's Forum for learning how to build wealth and financial freedom the Fastlane way!

Say "NO" to mediocre living rife with jobs, ascetic frugality, and suffocating savings rituals— learn how to build a Fastlane business that pays both freedom and lifestyle affluence. Join our forum with more than 70,000 entrepreneurs who are making it happen.
Join for FREE Today
Get the books
Remove ads? Join Fastlane INSIDERS
(Registration removes this block)

HELP! Any regular expression experts here?

MJ DeMarco

I followed the science; all I found was money.
Staff member
FASTLANE INSIDER
EPIC CONTRIBUTOR
Read Rat-Race Escape!
Read Fastlane!
Read Unscripted!
Summit Attendee
Speedway Pass
Jul 23, 2007
35,646
142,234
Utah
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 to Fastlane Insiders.
  • Thread starter
  • Admin
  • #3

MJ DeMarco

I followed the science; all I found was money.
Staff member
FASTLANE INSIDER
EPIC CONTRIBUTOR
Read Rat-Race Escape!
Read Fastlane!
Read Unscripted!
Summit Attendee
Speedway Pass
Jul 23, 2007
35,646
142,234
Utah

ApparentHorizon

Platinum Contributor
Speedway Pass
Apr 1, 2016
942
2,810
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
 
Don't like ads? Remove them while supporting the forum: Subscribe to Fastlane Insiders.
  • Thread starter
  • Admin
  • #5

MJ DeMarco

I followed the science; all I found was money.
Staff member
FASTLANE INSIDER
EPIC CONTRIBUTOR
Read Rat-Race Escape!
Read Fastlane!
Read Unscripted!
Summit Attendee
Speedway Pass
Jul 23, 2007
35,646
142,234
Utah
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 Fastlane!
Read Unscripted!
Speedway Pass
Apr 29, 2017
130
383
31
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

I followed the science; all I found was money.
Staff member
FASTLANE INSIDER
EPIC CONTRIBUTOR
Read Rat-Race Escape!
Read Fastlane!
Read Unscripted!
Summit Attendee
Speedway Pass
Jul 23, 2007
35,646
142,234
Utah
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.
 
Don't like ads? Remove them while supporting the forum: Subscribe to Fastlane Insiders.
  • Thread starter
  • Admin
  • #8

MJ DeMarco

I followed the science; all I found was money.
Staff member
FASTLANE INSIDER
EPIC CONTRIBUTOR
Read Rat-Race Escape!
Read Fastlane!
Read Unscripted!
Summit Attendee
Speedway Pass
Jul 23, 2007
35,646
142,234
Utah
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]
 

Post New Topic

Please SEARCH before posting.
Please select the BEST category.

Post new topic

Guest post submissions offered HERE.

Must Read Books...

must read books
Download FREE and share!
Download
Explore books recommended by MJ DeMarco and other members of the Fastlane entrepreneurial community.
Fastlane Bookstore

New Topics

Fastlane Insiders

View the forum AD FREE.
Private, unindexed content
Detailed process/execution threads
Ideas needing execution, more!

Join Fastlane Insiders.

Top