Forum Moderators: phranque
I administer example.com and just converted the photo gallery from ugly popups to querystring based embeded awesomeness...
I found out that google hates these kind of urls:
http://www.example.com/light_brown/fuzzy_widgets/?ref=MMP2021&fil=TheFoo_ThursdayNightLounge_1142010_003.jpg&max=37
and could possibly love this URL:
http://www.example.com/light_brown/fuzzy_widgets/gallery/MMP2021/TheFoo/ThursdayNightLounge/1-14-2010/003.jpg
or
http://www.example.com/light_brown/fuzzy_widgets/gallery/MMP2021/TheFoo/ThursdayNightLounge/1-14-2010/003/
I managed to make this work:
http://www.example.com/light_brown/fuzzy_widgets/gallery/MMP2021/
with this code: (in the root of fuzzy_widgets)
RewriteEngine on
RewriteRule ^gallery/([A-Z,0-9]+)/?$ index.php?ref=$1&fil=$2
but the rest just baffles me.
can any one help?
thanks for your help in advance...
[edited by: jdMorgan at 9:24 pm (utc) on Jan. 21, 2010]
[edit reason] No URLs or specific keywords, please. See Terms of Service. [/edit]
Please be more specific. What else do you want to do that this rule does not do? Or is it something else?
You will need to 'expand' this rule to allow for the additional slash(es) in the SEO-friendly URLs, and you will need to include the "max" number in your SEO-friendly URLs.
Jim
I want to convert this made up directory structure: /fuzzy_widgets/gallery/MMP2021/TheFoo/ThursdayNightLounge/1-14-2010/003/
to this page as a querystring: /fuzzy_widgets/?ref=MMP2021&fil=TheFoo_ThursdayNightLounge_1142010_003.jpg
I would like to take each directory and build a 2nd querystring value (fil) and put them together via an underscore (_) and remove the dashes between the dates.
I figured out the 1st querystring, but adding a 2nd querysting that has to be build based on multiple directory structure values has got me a bit cookoo...
any help would be awesome!
As for dates, investigate the BigEndian format specified by RFC 3339, where today is 20100121 or 2010-01-21. With that format, files sort into date order when using an alphabetical filename sort, as well as being universally understood (unlike 2-1-2010 which means different things either side of the Atlantic).
See the regular-expressions tutorial cited in our Apache Forum Charter (link at top of this page) for important details.
Once all of the 'fields' are matched by parenthesized subpatterns, they can be back-referenced in the substitution URL by referring to them by number $1 through $9. See the mod_rewrite documentation at apache.org, especially the 'back-references' section and the description of RewriteCond and RewriteRule.
Something like this should get you started:
RewriteRule ^gallery/([A-Z0-9]+)/(A-Za-z)+/([A-Za-z]+)/([0-9]¦[1][012])-([012]?[0-9]¦3[01])-(2[0-9]{3})/[0-9]+$ index.php?ref=$1&fil=$2_$3_$4$5$6_$7 [L]