Embedded Blog and .htaccess Looping
Posted: Sat Nov 01, 2008 11:08 pm
Albeit, the looping part is of my own creation.
Since I'm using .htaccess and mod_rewrite to create the pages for the blog, I thought I'd be really sneaky and use it to my advantage to pull the blog entry titles out of .htaccess and plug them into the meta title head of my website template (the shell I embedded my s9y blog into).
Here is what I did to my .htaccess file:
RewriteRule ^((archives/([0-9]+)-([0-9a-z\.\_!;,\+\-\%]+)\.html)/?) unite.html?/$1&title=$4 [NC,L,QSA]
RewriteRule ^(authors/([0-9]+)-([0-9a-z\.\_!;,\+\-\%]+)) unite.html?/$1&title=$3 [NC,L,QSA]
RewriteRule ^(categories/([0-9;]+)-([0-9a-z\.\_!;,\+\-\%]+)) unite.html?/$1&title=$3 [NC,L,QSA]
Note the &title= at the end.
Now all I have to do is $_REQUEST the $title variable from the URLs, and voila I can plug them right into my HTML Head and output the titles right to the browser. If I didn't do this, then having the embedded blog means having a singular blog meta title for the whole blog, rather than giving each entry their own unique one. Make sense?
Problem: As you can probably see, the rewrites are now left wide open. Proof of this would be the spambots who have managed to be landing at URLs (I have proof of this in my stats) like this:
../archives/2008/css/css/css/css/css/css/css/css/css/css/css/css/css/css/
css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/
css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/
css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/
css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/
css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/
css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/
css/css/css/css/css/css/css/
and
../authors/css/print/css/login-signup/css/css/links/css/idea/css/css/
login-signup/login signup/accessibility/css/css/idea/css/main_redux/css/css/main_redux/
css/login-signup/css/login/css/print/css/login-signup/links/css/css/print/css/css/index/archives/css/idea/css/css/links.html
Literally about 5000 variations of this.
So, does anyone know a good way that I can grab the titles, and maybe even meta description/keywords for an entry to use with an embedded blog like I describe? The main site, and the blog, use separate databases, so I would like to avoid opening/closing multiple databases just to grab this miniscule amount of info. Maybe some type of conditional in the rewrite? Help!
Since I'm using .htaccess and mod_rewrite to create the pages for the blog, I thought I'd be really sneaky and use it to my advantage to pull the blog entry titles out of .htaccess and plug them into the meta title head of my website template (the shell I embedded my s9y blog into).
Here is what I did to my .htaccess file:
RewriteRule ^((archives/([0-9]+)-([0-9a-z\.\_!;,\+\-\%]+)\.html)/?) unite.html?/$1&title=$4 [NC,L,QSA]
RewriteRule ^(authors/([0-9]+)-([0-9a-z\.\_!;,\+\-\%]+)) unite.html?/$1&title=$3 [NC,L,QSA]
RewriteRule ^(categories/([0-9;]+)-([0-9a-z\.\_!;,\+\-\%]+)) unite.html?/$1&title=$3 [NC,L,QSA]
Note the &title= at the end.
Now all I have to do is $_REQUEST the $title variable from the URLs, and voila I can plug them right into my HTML Head and output the titles right to the browser. If I didn't do this, then having the embedded blog means having a singular blog meta title for the whole blog, rather than giving each entry their own unique one. Make sense?
Problem: As you can probably see, the rewrites are now left wide open. Proof of this would be the spambots who have managed to be landing at URLs (I have proof of this in my stats) like this:
../archives/2008/css/css/css/css/css/css/css/css/css/css/css/css/css/css/
css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/
css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/
css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/
css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/
css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/
css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/
css/css/css/css/css/css/css/
and
../authors/css/print/css/login-signup/css/css/links/css/idea/css/css/
login-signup/login signup/accessibility/css/css/idea/css/main_redux/css/css/main_redux/
css/login-signup/css/login/css/print/css/login-signup/links/css/css/print/css/css/index/archives/css/idea/css/css/links.html
Literally about 5000 variations of this.
So, does anyone know a good way that I can grab the titles, and maybe even meta description/keywords for an entry to use with an embedded blog like I describe? The main site, and the blog, use separate databases, so I would like to avoid opening/closing multiple databases just to grab this miniscule amount of info. Maybe some type of conditional in the rewrite? Help!