tags:

views:

9

answers:

1
+1  Q: 

Mod_rewrite rule

Would there be an easier way to do this with a regular expression?

RewriteRule ^2090024$ https://www.wsjwine.com/discovery_offer.aspx?promo=2090024 [L]
RewriteRule ^2090025$ https://www.wsjwine.com/discovery_offer.aspx?promo=2090025 [L]
RewriteRule ^2090013$ https://www.wsjwine.com/discovery_offer.aspx?promo=2090013 [L]

RewriteRule ^2078027$ https://www.wsjwine.com/discovery_offer.aspx?promo=2078027 [L]
RewriteRule ^2078028$ https://www.wsjwine.com/discovery_offer.aspx?promo=2078028 [L]
RewriteRule ^2078029$ https://www.wsjwine.com/discovery_offer.aspx?promo=2078029 [L]
RewriteRule ^2078030$ https://www.wsjwine.com/discovery_offer.aspx?promo=2078030 [L]

I feel like there is, but dont know mod_rewrite well enough.

A: 

Depends on the number formats you want to accept. If it's sufficient to just catch any 7 digit number:

RewriteRule ^([0-9]{7})$ https://www.wsjwine.com/discovery_offer.aspx?promo=$1 [L]

If it could be any number of digits (not just 7):

RewriteRule ^([0-9]+)$ https://www.wsjwine.com/discovery_offer.aspx?promo=$1 [L]
Jeff