ingenium Posted March 17, 2009 Share Posted March 17, 2009 Hi, I'm trying to use Friendly URLs with lighttpd instead of apache. I know I need to change the stuff in htaccess.txt to be lighttpd specific. So far, I have: url.rewrite-once = ( "^([a-zA-Z0-9-]*)/([0-9]+)\-([a-zA-Z0-9-]*)\.html(.*)$" => "product.php?id_product=$2$4" , "^([0-9]+)\-([a-zA-Z0-9-]*)\.html(.*)$" =>"product.php?id_product=$1$3" ) url.rewrite-once = ( "^([0-9]+)\-([a-zA-Z0-9-]*)(.*)$" =>"category.php?id_category=$1" , "^content/([0-9]+)\-([a-zA-Z0-9-]*)(.*)$" =>"cms.php?id_cms=$1" , "^([0-9]+)__([a-zA-Z0-9-]*)(.*)$" =>"supplier.php?id_supplier=$1$3" , "^([0-9]+)_([a-zA-Z0-9-]*)(.*)$" =>"manufacturer.php?id_manufacturer=$1$3" ) But the second statement gives me the error "parser failed somehow near here: (EOL)". I believe it's something with the QSA flag, since just using any one statement with that flag will give the error as well. Lighttpd docs here (http://redmine.lighttpd.net/wiki/lighttpd/MigratingFromApache) make mention of needing to add "(?:\?(.*))?", but I've never been very good at regular expressions and can't seem to figure it out.Combining all the rules into a single url.rewrite-once allows lighttpd to start, but clicking on one of the category links gives a 404 error, so the re-write is not occurring. The first statement, for dealing with the products, appears to work correctly. Link to comment Share on other sites More sharing options...
bzshow Posted June 19, 2009 Share Posted June 19, 2009 try this. url.rewrite-once = ( "^/([a-zA-Z0-9-]*)/([0-9]+)\-([a-zA-Z0-9-]*)\.html(\?(.*))?" => "/product.php?id_product=$2&$5" , "^/([0-9]+)\-([a-zA-Z0-9-]*)\.html(\?(.*))?" =>"/product.php?id_product=$1&$4", "^/([0-9]+)\-([a-zA-Z0-9-]*)(\?(.*))?" =>"/category.php?id_category=$1&$4" , "^/content/([0-9]+)\-([a-zA-Z0-9-]*)(\?(.*))?" =>"/cms.php?id_cms=$1&$4" , "^/([0-9]+)__([a-zA-Z0-9-]*)(\?(.*))?" =>"/supplier.php?id_supplier=$1&$4" , "^/([0-9]+)_([a-zA-Z0-9-]*)(\?(.*))?" =>"/manufacturer.php?id_manufacturer=$1&$4" ) Link to comment Share on other sites More sharing options...
ingenium Posted June 30, 2009 Author Share Posted June 30, 2009 Great! It works, thanks! Link to comment Share on other sites More sharing options...
Miguel Angel Posted February 17, 2010 Share Posted February 17, 2010 Try this code url.rewrite-once = ( "^/([a-z0-9]+)\-([a-z0-9]+)(\-[_a-zA-Z0-9-]*)/([_a-zA-Z0-9-]*)\.jpg$" => "/img/p/$1-$2$3.jpg", "^/([0-9]+)(\-[_a-zA-Z0-9-]*)/([_a-zA-Z0-9-]*)\.jpg$" => "/img/c/$1$2.jpg", "^/lang-([a-z]{2})/([a-zA-Z0-9-]*)/([0-9]+)\-([a-zA-Z0-9-]*)\.html(\?(.*))?" => "/product.php?id_product=$3&isolang;=$1$6" , "^/lang-([a-z]{2})/([0-9]+)\-([a-zA-Z0-9-]*)\.html(\?(.*))?" =>"/product.php?id_product=$2&isolang;=$1&$4", "^/lang-([a-z]{2})/content/([0-9]+)\-([a-zA-Z0-9-]*)(\?(.*))?" =>"/cms.php?id_cms=$2&isolang;=$1&$4", "^/lang-([a-z]{2})/([0-9]+)\-([a-zA-Z0-9-]*)(\?(.*))?" =>"/category.php?id_category=$2&isolang;=$1&$5" , "^/([a-zA-Z0-9-]*)/([0-9]+)\-([a-zA-Z0-9-]*)\.html(\?(.*))?" => "/product.php?id_product=$2&$5" , "^/([0-9]+)\-([a-zA-Z0-9-]*)\.html(\?(.*))?" =>"/product.php?id_product=$1&$4", "^/([0-9]+)\-([a-zA-Z0-9-]*)(\?(.*))?" =>"/category.php?id_category=$1&$4" , "^/content/([0-9]+)\-([a-zA-Z0-9-]*)(\?(.*))?" =>"/cms.php?id_cms=$1&$4" , "^/([0-9]+)__([a-zA-Z0-9-]*)(\?(.*))?" =>"/supplier.php?id_supplier=$1&$4" , "^/([0-9]+)_([a-zA-Z0-9-]*)(\?(.*))?" =>"/manufacturer.php?id_manufacturer=$1&$4", "^/lang-([a-z]{2})/(\?(.*))?" => "/index.php?isolang=$1&$2" ) this code has support to multi-language sites and fix the image 's url error Link to comment Share on other sites More sharing options...
Recommended Posts