Can I get some Lighttpd rewrite help please?

DDRtists

ɹoʇɐɹǝpoɯ ɹǝdns
Reaction score
415
Okay, so I've recently moved my webserver box from Server 2003 with Apache 2.2.x to Ubuntu Server 11.04 with Lighttpd. I like it way better, so much faster, however I'm setting up a store online for my mom using PrestaShop right now. It has the feature of "Friendly URL's", which I would like enabled. However, it doesn't have a settings file available for Lighttpd anywhere public that I can find, been looking for awhile.

Now, I've found a Lighttpd setup that people seem to be claiming works, but when I use it, everything works in terms of rewriting pages and what not, but the images for categories and items don't show up.
I'm not the greatest with htaccess and rewrite strings, so if anyone can help me out, that would be great. Heres the info I got:

This is my setup I'm currently using to rewrite on my lighttpd box:
Code:
	# ReWrite rules for the PrestaShop software.
	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 is the .htaccess code it generated for a Apache setup during setup:
Code:
# .htaccess automaticaly generated by PrestaShop e-commerce open-source solution
# WARNING: PLEASE DO NOT MODIFY THIS FILE MANUALLY. IF NECESSARY, ADD YOUR SPECIFIC CONFIGURATION WITH THE HTACCESS GENERATOR IN BACK OFFICE
# http://www.prestashop.com - http://www.prestashop.com/forums


<IfModule mod_rewrite.c>
# URL rewriting module activation
RewriteEngine on

# URL rewriting rules
RewriteRule ^api/?(.*)$ /webservice/dispatcher.php?url=$1 [QSA,L]
RewriteRule ^([a-z0-9]+)\-([a-z0-9]+)(\-[_a-zA-Z0-9-]*)/[_a-zA-Z0-9-]*\.jpg$ /img/p/$1-$2$3.jpg [L]
RewriteRule ^([0-9]+)\-([0-9]+)/[_a-zA-Z0-9-]*\.jpg$ /img/p/$1-$2.jpg [L]
RewriteRule ^([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$ /img/p/$1/$1$2.jpg [L]
RewriteRule ^([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$ /img/p/$1/$2/$1$2$3.jpg [L]
RewriteRule ^([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$ /img/p/$1/$2/$3/$1$2$3$4.jpg [L]
RewriteRule ^([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$ /img/p/$1/$2/$3/$4/$1$2$3$4$5.jpg [L]
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$ /img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6.jpg [L]
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7.jpg [L]
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8.jpg [L]
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9.jpg [L]
RewriteRule ^c/([0-9]+)(\-[_a-zA-Z0-9-]*)/[_a-zA-Z0-9-]*\.jpg$ /img/c/$1$2.jpg [L]
RewriteRule ^([0-9]+)\-[a-zA-Z0-9-]*\.html /product.php?id_product=$1 [QSA,L]
RewriteRule ^([0-9]+)\-[a-zA-Z0-9-]* /category.php?id_category=$1 [QSA,L]
RewriteRule ^[a-zA-Z0-9-]*/([0-9]+)\-[a-zA-Z0-9-]*\.html /product.php?id_product=$1 [QSA,L]
RewriteRule ^([0-9]+)__([a-zA-Z0-9-]*) /supplier.php?id_supplier=$1 [QSA,L]
RewriteRule ^([0-9]+)_([a-zA-Z0-9-]*) /manufacturer.php?id_manufacturer=$1 [QSA,L]
RewriteRule ^content/([0-9]+)\-([a-zA-Z0-9-]*) /cms.php?id_cms=$1 [QSA,L]
RewriteRule ^content/category/([0-9]+)\-([a-zA-Z0-9-]*) /cms.php?id_cms_category=$1 [QSA,L]
RewriteRule ^([0-9]+)(\-[_a-zA-Z0-9-]*)/[_a-zA-Z0-9-]*\.jpg$ /img/c/$1$2.jpg [L]
RewriteRule ^page-not-found$ /404.php [QSA,L]
RewriteRule ^address$ /address.php [QSA,L]
RewriteRule ^addresses$ /addresses.php [QSA,L]
RewriteRule ^authentication$ /authentication.php [QSA,L]
RewriteRule ^best-sales$ /best-sales.php [QSA,L]
RewriteRule ^cart$ /cart.php [QSA,L]
RewriteRule ^contact-us$ /contact-form.php [QSA,L]
RewriteRule ^discount$ /discount.php [QSA,L]
RewriteRule ^guest-tracking$ /guest-tracking.php [QSA,L]
RewriteRule ^order-history$ /history.php [QSA,L]
RewriteRule ^identity$ /identity.php [QSA,L]
RewriteRule ^manufacturers$ /manufacturer.php [QSA,L]
RewriteRule ^my-account$ /my-account.php [QSA,L]
RewriteRule ^new-products$ /new-products.php [QSA,L]
RewriteRule ^order$ /order.php [QSA,L]
RewriteRule ^order-follow$ /order-follow.php [QSA,L]
RewriteRule ^quick-order$ /order-opc.php [QSA,L]
RewriteRule ^order-slip$ /order-slip.php [QSA,L]
RewriteRule ^password-recovery$ /password.php [QSA,L]
RewriteRule ^prices-drop$ /prices-drop.php [QSA,L]
RewriteRule ^search$ /search.php [QSA,L]
RewriteRule ^sitemap$ /sitemap.php [QSA,L]
RewriteRule ^stores$ /stores.php [QSA,L]
RewriteRule ^supplier$ /supplier.php [QSA,L]
</IfModule>

# Catch 404 errors
ErrorDocument 404 /404.php

They don't provide a setup for lighttpd from what I can find, sadly. The category and item photos don't show up, the category photos are linked in the fashion of "http://store.mystore.com/-home/.jpg", and the item photos are linked as "http://store.mystore.com/55-medium/test.jpg". I'm sure that first one is wrong, not sure about the second. The photos are indeed in the locations they are supposed to be at for the rewrites, too. They show up fine if I turn the rewrite feature off.

If someone could help me figure out the correct string, or point me to a lighttpd setup, that would be awesome.
Also, if you don't quite understand what I mean and you are good with this stuff and wanna see yourself, PM me and I'll shoot you the link. It's a public site, but I don't really want it publicly linked on this site. :)
 

Magentix

if (OP.statement == false) postCount++;
Reaction score
107
Looking at the rewrite rules it generated, one question pops to mind: Who designed this shit?
(Not helpful, I know, but still...)
 

DDRtists

ɹoʇɐɹǝpoɯ ɹǝdns
Reaction score
415
Looking at the rewrite rules it generated, one question pops to mind: Who designed this shit?
(Not helpful, I know, but still...)

Well, I don't know much about this stuff as of right now, but I thought the same thing. I looked at it and thought "there has to be a less repetitive way to do this...". Lol
But oh well, I just find it amazing that with software as big as PrestaShop, that they only offer a .htaccess config and nothing else. Lighttpd is what most people on linux use...
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
889
Lighttpd is nice but it is still Apache that is most popular on Linux. The LAMP stack (Linux Apache MySQL PHP) is the big one in the industry.
Now then, if you want to experiment, try out Litespeed (http://litespeedtech.com). It supports the standard Apache .htaccess files and rewrite rules but is a whole lot faster.

As for what you have there, do you have any virtual hosts setup? If so, where is that rewrite block located? In the virtual host itself or in the main config file?
 

DDRtists

ɹoʇɐɹǝpoɯ ɹǝdns
Reaction score
415
I indeed do have vhosts set up, and the rewrite block is located inside the vhost setup for that one site.
This is the vhost setup for the site at hand, and all the vhost settings are placed at the very bottom of the lighttpd.conf file.

Code:
# store.mysite.com VHost Setup
$HTTP["host"] =~ "(^|\.)store.mysite.com$" {
	server.document-root =		"/Web-store/www/store.mysite.com/htdocs"
	server.errorlog =		"/Web-store/www/store.mysite.com/logs/error.log"
	accesslog.filename =		"/Web-store/www/store.mysite.com/logs/access.log"
	server.error-handler-404 =	"/Web-store/www/store.mysite.com/htdocs/404.php"

	# ReWrite rules for the PrestaShop software.
	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"
	)
}
 

DDRtists

ɹoʇɐɹǝpoɯ ɹǝdns
Reaction score
415
Got it.

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",
		"^/c/([0-9]+)(\-[_a-zA-Z0-9-]*)/([_a-zA-Z0-9-]*)\.jpg$" => "/img/c/$1$2.jpg",
		"^/([0-9]+)\-([0-9]+)/[_a-zA-Z0-9-]*\.jpg$" => "/img/p/$1-$2.jpg",
		"^/([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$" => "/img/p/$1/$1$2.jpg",
		"^/([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$" => "/img/p/$1/$2/$1$2$3.jpg",
		"^/([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$" => "/img/p/$1/$2/$3/$1$2$3$4.jpg",
		"^/([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$" => "/img/p/$1/$2/$3/$4/$1$2$3$4$5.jpg",
		"^/([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$" => "/img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6.jpg",
		"^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$" => "/img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7.jpg",
		"^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$" => "/img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8.jpg",
		"^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$" => "/img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9.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"
	)
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top