Solved

Pattern Matching Issue

Posted on 2014-01-31
6
183 Views
Last Modified: 2014-02-13
I have this url I need to regex to another link.  Here is the original link.

Tei%20Fu%20&%20Peppermint%20Oils%20w/%20Carrying%20Case_p_814.htm

Here is what I have tried
RedirectMatch 301 ^/Tei((%20)|[\s\w\/\.\-])Fu((%20)|[\s\w\/\.\-])&((%20)|[\s\w\/\.\-])Peppermint((%20)|[\s\w\/\.\-])Oils((%20)|[\s\w\/\.\-])w/((%20)|[\s\w\/\.\-])Carrying((%20)|[\s\w\/\.\-])Case_p_814\.htm$ /product.php?productid=56

In the browser it defaults to a discontinued page with this url
http://www.abc.com/tei-fu-peppermint-oils-w-carrying-case.html

Please tell me how to fix this?

Randal
0
Comment
Question by:sharingsunshine
  • 3
  • 2
6 Comments
 
LVL 37

Expert Comment

by:Gerwin Jansen
ID: 39825508
%20 is a space, %2d is a hyphen, try substituting %20 with %2d in your pattern.
0
 

Author Comment

by:sharingsunshine
ID: 39825516
I changed the %20 to %2d but it didn't make any difference.  I think the problem may be with the w/ in the url. But I am not sure how to escape  it properly.  Between the word Oils and Carrying.
0
 
LVL 9

Expert Comment

by:Derek Jensen
ID: 39826599
A backslash:
w\/

And yeah, stick with the %20, as that's how .htaccess sees it. :-)
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:sharingsunshine
ID: 39827095
I stuck with the %20 and fixed the w\/ but it still won't match.  So can you see what the problem is?
0
 
LVL 9

Accepted Solution

by:
Derek Jensen earned 500 total points
ID: 39848797
Are you escaping all of your forward slashes?
0
 

Author Closing Comment

by:sharingsunshine
ID: 39857141
thanks, that did it.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
RewriteRule in .htaccess file not working 8 51
Best IDE for PHP starters 11 101
Mac Online Backups 7 49
LINUX CENTOS + APACHE 9 37
In this article we will discuss some EI Capitan Mail app issues and provide some manual process to resolve them.
In this article we have discussed about the OS X EI Capitan and how to fix Wi-Fi issue in OS X El Capitan. We have explained how to delete system level preferences and create a new Wi-Fi location to resolve Wi-Fi issue.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now