Forum Moderators: phranque

Message Too Old, No Replies

mod_rewrite question

How can I get mod_rewrite to use a wildcard in the url?

         

MLHmptn

8:16 am on May 21, 2006 (gmt 0)

10+ Year Member



Hopefully somebody can tell me how to get this to work. I recently changed one of my OSCommerce sites to Ultimate SEO Urls and now I'm getting some duplicate pages as follows.

Problem URL: -c-0_240_274.html

I would like to rewrite these duplicate URL's so that the -c-0_240_274.html would be -c-240_274.html.

Hopefully somebody can tell me the syntax.

Thank you in advance!

jdMorgan

2:40 pm on May 23, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It's not clear which part of the URL is fixed and which part is variable, nor is it clear how to identify the 'duplicate' part or how many/what type of characters each 'field' is expected to have. But this should demonstrate using constrained variable fields (rather than wildcards) generally:

RewriteRule ^(-[a-z]-)[0-9]+_([0-9]+_[0-9]+)\.html$ /$1$2.html [L]

$1 and $2 refer to the values matching the parenthesized sub-expressions in the requested URL.

For more information, see the documents cited in our forum charter [webmasterworld.com] and the tutorials in the Apache forum section of the WebmasterWorld library [webmasterworld.com].

Jim