<?xml version="1.0" encoding="UTF-8"?><rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
> <channel><title>Comments on: Lighttpd Drupal CMS Clean URL ( SEO ) Rules Set Configuration</title> <atom:link href="http://www.cyberciti.biz/tips/lighttpd-drupal-htacess-seo-clean-urls.html/feed" rel="self" type="application/rss+xml" /><link>http://www.cyberciti.biz/tips/lighttpd-drupal-htacess-seo-clean-urls.html</link> <description>This is a Linux sys admin journal by Vivek about sys admin work, Linux tips &#38; tricks, hacks, news and more.</description> <lastBuildDate>Fri, 10 Feb 2012 20:37:43 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <item><title>By: James</title><link>http://www.cyberciti.biz/tips/lighttpd-drupal-htacess-seo-clean-urls.html#comment-144754</link> <dc:creator>James</dc:creator> <pubDate>Sun, 24 Aug 2008 20:31:27 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/?p=2544#comment-144754</guid> <description>Hi .. can someone with expertise in lighty rules please help..I am using Drupal CMS on a LLMP stack and I am stuck on trying
to come up with rules for a particular module I am wanting to use.
In lighttpd.conf I have:
========================
$HTTP[&quot;host&quot;] =~ &quot;(^&#124;\.)mydomain\.com&quot; {
server.document-root        = &quot;/var/www/public_html/mydomain.com/&quot;
index-file.names = ( &quot;index.php&quot; )
# for clean urls
magnet.attract-physical-path-to = (&quot;/etc/lighttpd/rewrite_drupal.lua&quot;)
}
In rewrite_drupal.lua I have:
==============================
-- little helper function
function file_exists(path)
local attr = lighty.stat(path)
if (attr) then
return true
else
return false
end
end
function removePrefix(str, prefix)
return str:sub(1,#prefix+1) == prefix..&quot;/&quot; and str:sub(#prefix+2)
end
-- prefix without the trailing slash
-- If reverting back to production mode comment in the above line and uncomment the line below
local prefix = &#039;&#039;
-- the magic ;)
if (not file_exists(lighty.env[&quot;physical.path&quot;])) then
-- file still missing. pass it to the fastcgi backend
request_uri = removePrefix(lighty.env[&quot;uri.path&quot;], prefix)
if request_uri then
lighty.env[&quot;uri.path&quot;]          = prefix .. &quot;/index.php&quot;
local uriquery = lighty.env[&quot;uri.query&quot;] or &quot;&quot;
lighty.env[&quot;uri.query&quot;] = uriquery .. (uriquery ~= &quot;&quot; and &quot;&amp;&quot; or &quot;&quot;) .. &quot;q=&quot; .. request_uri
lighty.env[&quot;physical.rel-path&quot;] = lighty.env[&quot;uri.path&quot;]
lighty.env[&quot;request.orig-uri&quot;]  = lighty.env[&quot;request.uri&quot;]
lighty.env[&quot;physical.path&quot;]     = lighty.env[&quot;physical.doc-root&quot;] .. lighty.env[&quot;physical.rel-path&quot;]
end
end
-- fallthrough will put it back into the lighty request loop
-- that means we get the 304 handling for free. ;)
----------------------------------------------------------------------------------
Given the above here is my question :
I want to know how to enable the following rules for a drupal module called &quot;boost&quot; which tries
to serve cached html pages bypassing php/drupal and the database. There is a write-up on this
at: http://codesorcery.net/2007/07/23/boost-your-drupal-site
Now for this Drupal module to work, there are rewrite rules needed.  Currently the module author
has noly provided htaccess rules for Apache.  I need lighttpd rules.   I have pasted above the rules
I currently have in lighttpd.conf and rewrite_drupal.lua file.  Can someone pls help me with the rules to
add to the lua or the lighttpd.conf file to make this module work.
I am pasting below the htaccess rules specific to this module that the author is recommending.  If anyone
has any suggestions on how it can work with lighttpd that would be a big help.
# Apache htaccess Rewrite rules for static page caching provided by the Boost module:
# BOOST START
Header add Expires &quot;Sun, 19 Nov 1978 05:00:00 GMT&quot;
Header add Cache-Control &quot;no-store, no-cache, must-revalidate, post-check=0, pre-check=0&quot;
AddCharset utf-8 .html
RewriteCond %{REQUEST_METHOD} ^GET$
RewriteCond %{REQUEST_URI} ^/$
RewriteCond %{QUERY_STRING} ^$
RewriteCond %{HTTP_COOKIE} !DRUPAL_UID
RewriteCond %{DOCUMENT_ROOT}/cache/%{SERVER_NAME}/0/index.html -f
RewriteRule ^(.*)$ cache/%{SERVER_NAME}/0/index.html [L]
RewriteCond %{REQUEST_METHOD} ^GET$
RewriteCond %{REQUEST_URI} !^/cache
RewriteCond %{REQUEST_URI} !^/user/login
RewriteCond %{REQUEST_URI} !^/admin
RewriteCond %{QUERY_STRING} ^$
RewriteCond %{HTTP_COOKIE} !DRUPAL_UID
RewriteCond %{DOCUMENT_ROOT}/cache/%{SERVER_NAME}/0%{REQUEST_URI} -d
RewriteCond %{DOCUMENT_ROOT}/cache/%{SERVER_NAME}/0%{REQUEST_URI}/index.html -f
RewriteRule ^(.*)$ cache/%{SERVER_NAME}/0/$1/index.html [L]
RewriteCond %{REQUEST_METHOD} ^GET$
RewriteCond %{REQUEST_URI} !^/cache
RewriteCond %{REQUEST_URI} !^/user/login
RewriteCond %{REQUEST_URI} !^/admin
RewriteCond %{QUERY_STRING} ^$
RewriteCond %{HTTP_COOKIE} !DRUPAL_UID
RewriteCond %{DOCUMENT_ROOT}/cache/%{SERVER_NAME}/0%{REQUEST_URI}.html -f
RewriteRule ^(.*)$ cache/%{SERVER_NAME}/0/$1.html [L]
# BOOST END
# Rewrite current-style URLs of the form &#039;index.php?q=x&#039;.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA] </description> <content:encoded><![CDATA[<p>Hi .. can someone with expertise in lighty rules please help..I am using Drupal CMS on a LLMP stack and I am stuck on trying</p><p>to come up with rules for a particular module I am wanting to use.</p><p>In lighttpd.conf I have:<br
/> ========================<br
/> $HTTP["host"] =~ &#8220;(^|\.)mydomain\.com&#8221; {<br
/> server.document-root        = &#8220;/var/www/public_html/mydomain.com/&#8221;<br
/> index-file.names = ( &#8220;index.php&#8221; )<br
/> # for clean urls<br
/> magnet.attract-physical-path-to = (&#8220;/etc/lighttpd/rewrite_drupal.lua&#8221;)<br
/> }</p><p>In rewrite_drupal.lua I have:<br
/> ==============================<br
/> &#8211; little helper function<br
/> function file_exists(path)<br
/> local attr = lighty.stat(path)<br
/> if (attr) then<br
/> return true<br
/> else<br
/> return false<br
/> end<br
/> end<br
/> function removePrefix(str, prefix)<br
/> return str:sub(1,#prefix+1) == prefix..&#8221;/&#8221; and str:sub(#prefix+2)<br
/> end</p><p>&#8211; prefix without the trailing slash</p><p>&#8211; If reverting back to production mode comment in the above line and uncomment the line below</p><p>local prefix = &#8221;</p><p>&#8211; the magic ;)<br
/> if (not file_exists(lighty.env["physical.path"])) then<br
/> &#8212; file still missing. pass it to the fastcgi backend<br
/> request_uri = removePrefix(lighty.env["uri.path"], prefix)<br
/> if request_uri then<br
/> lighty.env["uri.path"]          = prefix .. &#8220;/index.php&#8221;<br
/> local uriquery = lighty.env["uri.query"] or &#8220;&#8221;<br
/> lighty.env["uri.query"] = uriquery .. (uriquery ~= &#8220;&#8221; and &#8220;&amp;&#8221; or &#8220;&#8221;) .. &#8220;q=&#8221; .. request_uri<br
/> lighty.env["physical.rel-path"] = lighty.env["uri.path"]<br
/> lighty.env["request.orig-uri"]  = lighty.env["request.uri"]<br
/> lighty.env["physical.path"]     = lighty.env["physical.doc-root"] .. lighty.env["physical.rel-path"]<br
/> end<br
/> end<br
/> &#8211; fallthrough will put it back into the lighty request loop<br
/> &#8211; that means we get the 304 handling for free. ;)</p><p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p><p>Given the above here is my question :</p><p>I want to know how to enable the following rules for a drupal module called &#8220;boost&#8221; which tries<br
/> to serve cached html pages bypassing php/drupal and the database. There is a write-up on this<br
/> at: <a
href="http://codesorcery.net/2007/07/23/boost-your-drupal-site" rel="nofollow">http://codesorcery.net/2007/07/23/boost-your-drupal-site</a></p><p>Now for this Drupal module to work, there are rewrite rules needed.  Currently the module author<br
/> has noly provided htaccess rules for Apache.  I need lighttpd rules.   I have pasted above the rules<br
/> I currently have in lighttpd.conf and rewrite_drupal.lua file.  Can someone pls help me with the rules to<br
/> add to the lua or the lighttpd.conf file to make this module work.</p><p>I am pasting below the htaccess rules specific to this module that the author is recommending.  If anyone<br
/> has any suggestions on how it can work with lighttpd that would be a big help.</p><p> # Apache htaccess Rewrite rules for static page caching provided by the Boost module:<br
/> # BOOST START</p><p> Header add Expires &#8220;Sun, 19 Nov 1978 05:00:00 GMT&#8221;<br
/> Header add Cache-Control &#8220;no-store, no-cache, must-revalidate, post-check=0, pre-check=0&#8243;</p><p> AddCharset utf-8 .html</p><p> RewriteCond %{REQUEST_METHOD} ^GET$<br
/> RewriteCond %{REQUEST_URI} ^/$<br
/> RewriteCond %{QUERY_STRING} ^$<br
/> RewriteCond %{HTTP_COOKIE} !DRUPAL_UID<br
/> RewriteCond %{DOCUMENT_ROOT}/cache/%{SERVER_NAME}/0/index.html -f<br
/> RewriteRule ^(.*)$ cache/%{SERVER_NAME}/0/index.html [L]<br
/> RewriteCond %{REQUEST_METHOD} ^GET$<br
/> RewriteCond %{REQUEST_URI} !^/cache<br
/> RewriteCond %{REQUEST_URI} !^/user/login<br
/> RewriteCond %{REQUEST_URI} !^/admin<br
/> RewriteCond %{QUERY_STRING} ^$<br
/> RewriteCond %{HTTP_COOKIE} !DRUPAL_UID<br
/> RewriteCond %{DOCUMENT_ROOT}/cache/%{SERVER_NAME}/0%{REQUEST_URI} -d<br
/> RewriteCond %{DOCUMENT_ROOT}/cache/%{SERVER_NAME}/0%{REQUEST_URI}/index.html -f<br
/> RewriteRule ^(.*)$ cache/%{SERVER_NAME}/0/$1/index.html [L]<br
/> RewriteCond %{REQUEST_METHOD} ^GET$<br
/> RewriteCond %{REQUEST_URI} !^/cache<br
/> RewriteCond %{REQUEST_URI} !^/user/login<br
/> RewriteCond %{REQUEST_URI} !^/admin<br
/> RewriteCond %{QUERY_STRING} ^$<br
/> RewriteCond %{HTTP_COOKIE} !DRUPAL_UID<br
/> RewriteCond %{DOCUMENT_ROOT}/cache/%{SERVER_NAME}/0%{REQUEST_URI}.html -f<br
/> RewriteRule ^(.*)$ cache/%{SERVER_NAME}/0/$1.html [L]<br
/> # BOOST END</p><p> # Rewrite current-style URLs of the form &#8216;index.php?q=x&#8217;.<br
/> RewriteCond %{REQUEST_FILENAME} !-f<br
/> RewriteCond %{REQUEST_FILENAME} !-d<br
/> RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]</p> ]]></content:encoded> </item> <item><title>By: S. Nilesh</title><link>http://www.cyberciti.biz/tips/lighttpd-drupal-htacess-seo-clean-urls.html#comment-144608</link> <dc:creator>S. Nilesh</dc:creator> <pubDate>Fri, 08 Aug 2008 18:07:19 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/?p=2544#comment-144608</guid> <description>Vivek, this one is not a good method... exploit drupal internally. Set lighttpd&#039;s 404 handler to /index.php and add the following code in settings.php located in /sites/default/settings.php
&lt;pre&gt;if (strpos($_SERVER[&#039;SERVER_SOFTWARE&#039;], &#039;lighttpd&#039;) !== false) {
$_lighty_url = $base_url.$_SERVER[&#039;REQUEST_URI&#039;];
$_lighty_url = @parse_url($_lighty_url);
if ($_lighty_url[&#039;path&#039;] != &#039;/index.php&#039; &amp;&amp; $_lighty_url[&#039;path&#039;] != &#039;/&#039;) {
$_SERVER[&#039;QUERY_STRING&#039;] = $_lighty_url[&#039;query&#039;];
parse_str($_lighty_url[&#039;query&#039;], $_lighty_query);
foreach ($_lighty_query as $key =&gt; $val)
$_GET[$key] = $_REQUEST[$key] = $val;
$_GET[&#039;q&#039;] = $_REQUEST[&#039;q&#039;] = substr($_lighty_url[&#039;path&#039;], 1);
}
}&lt;/pre&gt;
This doesn&#039;t return a 404 by the server if there exists content. :)</description> <content:encoded><![CDATA[<p>Vivek, this one is not a good method&#8230; exploit drupal internally. Set lighttpd&#8217;s 404 handler to /index.php and add the following code in settings.php located in /sites/default/settings.php</p><pre>if (strpos($_SERVER['SERVER_SOFTWARE'], 'lighttpd') !== false) {
    $_lighty_url = $base_url.$_SERVER['REQUEST_URI'];
    $_lighty_url = @parse_url($_lighty_url);
    if ($_lighty_url['path'] != '/index.php' &amp;&amp; $_lighty_url['path'] != '/') {
        $_SERVER['QUERY_STRING'] = $_lighty_url['query'];
        parse_str($_lighty_url['query'], $_lighty_query);
        foreach ($_lighty_query as $key =&gt; $val)
            $_GET[$key] = $_REQUEST[$key] = $val;
        $_GET['q'] = $_REQUEST['q'] = substr($_lighty_url['path'], 1);
    }
}</pre><p>This doesn&#8217;t return a 404 by the server if there exists content. :)</p> ]]></content:encoded> </item> <item><title>By: vivek</title><link>http://www.cyberciti.biz/tips/lighttpd-drupal-htacess-seo-clean-urls.html#comment-144512</link> <dc:creator>vivek</dc:creator> <pubDate>Thu, 31 Jul 2008 04:11:48 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/?p=2544#comment-144512</guid> <description>BlueT,
The post has been updated. Appreciate your post.</description> <content:encoded><![CDATA[<p>BlueT,</p><p>The post has been updated. Appreciate your post.</p> ]]></content:encoded> </item> <item><title>By: BlueT</title><link>http://www.cyberciti.biz/tips/lighttpd-drupal-htacess-seo-clean-urls.html#comment-144510</link> <dc:creator>BlueT</dc:creator> <pubDate>Wed, 30 Jul 2008 20:48:12 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/?p=2544#comment-144510</guid> <description>Don&#039;t forget to enable mod_rewrite, or you&#039;ll face critical problem :-P</description> <content:encoded><![CDATA[<p>Don&#8217;t forget to enable mod_rewrite, or you&#8217;ll face critical problem :-P</p> ]]></content:encoded> </item> </channel> </rss>
