regex backreference

New to mod_rewrite? This is a good place to start.

regex backreference

Postby alud » Sat Jul 18, 2009 4:29 pm

Hello,
I've been trying of make a RewriteRule which contain a regex back reference in the pattern.

I've
textX/VAR/VAR_textZ.html a I want to rewrite to another thing (that thing isn't important...)
VAR is a variable text...

The point is how I match VAR as a regular expresion in mod_rewrite.

I tried with this, using regular expression backreference but it fails:
RewriteRule ^textX/\([^/]+\)/\1_textZ\.html$ "http://dest_url....$1." [R=301,L]

thanks in advance....
alud
 
Posts: 4
Joined: Sat Jul 18, 2009 4:18 pm

Postby richardk » Sun Jul 19, 2009 5:30 pm

You should not be escaping the ().

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^textX/([^/]+)/\1_textZ\.html$ http://dest_url/$1 [R=301,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

thanks

Postby alud » Sun Jul 19, 2009 6:56 pm

Thanks R it' worked perfect...

best regards,
alud
 
Posts: 4
Joined: Sat Jul 18, 2009 4:18 pm


Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 33 guests

cron