Regular expression help

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

Post Reply
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

Regular expression help

Post by itsmani1 »

Hi,

I need help in Regular expression.

For:

Code: Select all

http://test.example.com/MyPaper/Jobs-13-02-2011
I tried:

Code: Select all

RewriteRule ^MyPaper/Jobs-([0-9][0-9]\-[0-9][0-9]\-[0-9][0-9][0-9][0-9]) /test.php?cat_id=1&date=$2&paper_id=1
But it did not work... help please?

Thanks
User avatar
ridgerunner
Forum Contributor
Posts: 214
Joined: Sun Jul 05, 2009 10:39 pm
Location: SLC, UT

Re: Regular expression help

Post by ridgerunner »

Your rewrite rule works just fine for me (that is, the redirection worked). I placed the following .htaccess file in the root directory and the rewrite works as expected.
[text]# Check if we have the mod_rewrite module available...
<IfModule mod_rewrite.c>

# Turn on the rewrite engine.
RewriteEngine on

RewriteRule ^MyPaper/Jobs-([0-9][0-9]\-[0-9][0-9]\-[0-9][0-9][0-9][0-9]) /test.php?cat_id=1&date=$2&paper_id=1
</IfModule>
[/text]
You did not provide any information about the type of error you received (more information is better). Here are a couple suggestions:
Ensure mod_rewrite is turned on.
Put the .htaccess in the root folder of your domain.

:)
Post Reply