Вопрос

I have two intertwined problems to solve.

My stock photography website is driven by a PERL-scripted program called ImageFolio, purchased in 2005. The program allows for display of photos by categories, or by searching keywords, which then deliver pages of thumbnail images matching the contents of an entire category, or images with keywords or image titles matching the search terms. Clicking a thumbnail image displays a dynamically generated page showing a larger view of the image.

Since the same images can be displayed from multiple searches, it's important to designate a canonical page in the HEAD section of the dynamically generated pages by using a RegEx expression to capture the relevant variable information from the dynamic URL, to create and specify a link rel="canonical" tag in the HEAD section of each page. Corresponding MOD_REWRITE statements are required in the .htaccess file to translate those static canonical links back to properly structured dynamic links to deliver the proper content.

Some typical dynamically generated URLs and preferred static URL substitutes are:

Direct link to a "category" displaying a page of thumbnails from that category
DYNAMIC: www.artminds.com/cgi-bin/ImageFolio4/imageFolio.cgi?direct=Athletics_and_Sports
DESIRED STATIC CANONICAL: www.artminds.com/stock-photos/Athletics-and-Sports
MOD_REWRITE: Same as dynamic above

Search for images by clicking a clickable keyword on an image page
DYNAMIC: www.artminds.com/cgi-bin/ImageFolio4/imageFolio.cgi?img=0&search=six%20pack&cat=all&bool=phrase
DESIRED STATIC CANONICAL: www.artminds.com/photo-search/six-pack.html
MOD_REWRITE: /cgi-bin/ImageFolio4/imageFolio.cgi?search=six+pack

Search for images by typing a keyword in the search box
DYNAMIC: www.artminds.com/cgi-bin/ImageFolio4/imageFolio.cgi?search=six+pack&bool=and&cat=&x=0&y=0
DESIRED STATIC CANONICAL: www.artminds.com/six-pack.html
MOD_REWRITE: /cgi-bin/ImageFolio4/imageFolio.cgi?search=six+pack

Display single image page from clicking a thumbnail
DYNAMIC: www.artminds.com/cgi-bin/ImageFolio4/imageFolio.cgi?action=view&link=On_Location&image=103_8310.jpg&img=0&search=six%20pack&cat=all&tt=&bool=and
DESIRED STATIC CANONICAL: www.artminds.com/103_8310/Muscular-young-man-posing-shirtless-with-cowboy-hat-and-blue-jeans.html
MOD_REWRITE: /cgi-bin/ImageFolio4/imageFolio.cgi?action=view&link=On_Location&image=103_8310

Note: The long file name in the DESIRED CANONICAL immediately above comes from the image caption which is displayed in the HTML Title Tag of the image display page, retrieved via variables in the script program that extract the embedded meta-data in the image file. Additional variables in the dynamic URL reveal the source of the thumbnail display that was clicked, i.e., direct link to category, or based on a search keywords, and whether the search was limited to one category and whether the search was interpreted as and/or/phrase but is not required to specifically identify that image display page from all other html pages

In the dynamic examples above, while there may be multiple variables, usually only one is relevant and needs to be captured both for converting to the static URL as wells as in the Mod_rewrite to convert the static to a dynamic URL, as shown in the MOD_REWRITE examples above.

Any help would be very much appreciated.

Thanks,
Art Minds
Pasadena, CA

Это было полезно?

Решение

Thanks to @ruakh I solved this problem by posting a simpler version of the question. Here is the solution to capture a portion of a static URL in any of the three following forms and pass it as a parameter to my CGI script which conducts the search:

http://www.artminds.com/photo-search/outdoors

http://www.artminds.com/photo-search/outdoors/

`http://www.artminds.com/photo-search/outdoors.html

RewriteRule ^photo-search\/([^/]+?)(/|\.html|)$ http://www.artminds.com/cgi-bin/ImageFolio4/imageFolio.cgi\?search=$1&bool\=all [R]

Другие советы

What did you wind up using for the direct links?

"Direct link to a "category" displaying a page of thumbnails from that category DYNAMIC: www.artminds.com/cgi-bin/ImageFolio4/imageFolio.cgi?direct=Athletics_and_Sports DESIRED STATIC CANONICAL: www.artminds.com/stock-photos/Athletics-and-Sports MOD_REWRITE: Same as dynamic above"

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top