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

Welcome to the only entrepreneur forum dedicated to building life-changing wealth.

Build a Fastlane business. Earn real financial freedom. Join free.

Join over 80,000 entrepreneurs who have rejected the paradigm of mediocrity and said "NO!" to underpaid jobs, ascetic frugality, and suffocating savings rituals— learn how to build a Fastlane business that pays both freedom and lifestyle affluence.

Free registration at the forum 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
User Power
Value/Post Ratio
446%
Jul 23, 2007
38,169
170,290
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
 
Dislike ads? Remove them and support 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
User Power
Value/Post Ratio
446%
Jul 23, 2007
38,169
170,290
Utah

ApparentHorizon

Platinum Contributor
Speedway Pass
User Power
Value/Post Ratio
301%
Apr 1, 2016
942
2,838
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
 
Dislike ads? Remove them and support 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
User Power
Value/Post Ratio
446%
Jul 23, 2007
38,169
170,290
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
User Power
Value/Post Ratio
302%
Apr 29, 2017
130
392
32
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
User Power
Value/Post Ratio
446%
Jul 23, 2007
38,169
170,290
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.
 
Dislike ads? Remove them and support 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
User Power
Value/Post Ratio
446%
Jul 23, 2007
38,169
170,290
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.

Latest Posts

New Topics

Fastlane Insiders

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

Join Fastlane Insiders.

Top