l i n u x - u s e r s - g r o u p - o f - d a v i s
L U G O D
 
Next Meeting:
August 5: Social gathering
Next Installfest:
TBD
Latest News:
Jul. 4: July, August and September: Security, Photography and Programming for Kids
Page last updated:
2009 Apr 20 21:02

The following is an archive of a post made to our 'vox-tech mailing list' by one of its subscribers.

Report this post as spam:

(Enter your email address)
[vox-tech] Question related to Apache mod_rewrite and regularexpressions
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[vox-tech] Question related to Apache mod_rewrite and regularexpressions



I've killed the better part of the morning and this afternon trying to  
figure out this use of Apache's mod_rewrite. What I'm trying to do is  
this:

For the sake of backward compatibility, I'd like to take series of  
discrete pages that were created with HTML and generalize them with a  
database lookup page in PHP. Some example URLs would be like this:

product-This-Product.php
product-Another-Product.php
product-Yet-More-Product.php
product-Lotta-Product.php

and convert them within Apache internally to pages like this:

product.php?name=This-Product
product.php?name=Another-Product
product.php?name=Yet-More-Product
product.php?name=Lotta-Product

I'm the first to admit that I'm not a whiz with either RegEx or  
Apache. However, after a lot of reading, I came up with this:

RewriteEngine On
RewriteRule ^/?product-([A-Za-z0-9-]+)\.php$ product.php?name=$1  
[ R=301,L]

But Apache is choking on it so I can't even figure out how close I am  
to getting it working.

To further make things difficult, I need to skip over other pages that  
aren't product related. Is there somebody out there who can crack this  
nut?

Thanks so much!

-- Dave Spencer, PageWeavers
_______________________________________________
vox-tech mailing list
vox-tech@lists.lugod.org
http://lists.lugod.org/mailman/listinfo/vox-tech



LinkedIn
LUGOD Group on LinkedIn
Sign up for LUGOD event announcements
Your email address:
facebook
LUGOD Group on Facebook
'Like' LUGOD on Facebook:

Hosting provided by:
Sunset Systems
Sunset Systems offers preconfigured Linux systems, remote system administration and custom software development.

LUGOD: Linux Users' Group of Davis
PO Box 2082, Davis, CA 95617
Contact Us

LUGOD is a 501(c)7 non-profit organization
based in Davis, California
and serving the Sacramento area.
"Linux" is a trademark of Linus Torvalds.

Sponsored in part by:
Appahost Applications
For a significant contribution towards our projector, and a generous donation to allow us to continue meeting at the Davis Library.