Project

General

Profile

[NoResponse] help convert apache htaccess [L,QSA] rewrite rules to lighttpd

Added by Mister 4 months ago

Hello,
i'm looking to convert this .htaccess file to lighttpd rewrite rule ?

RewriteRule ^admin$ admin.php
RewriteRule ^page=([0-9]+)$ index.php?cat=$1 [L,QSA]
RewriteRule ^sitemap$ index.php?route=html
RewriteRule ^login$ index.php?route=login
RewriteRule ^signup$ index.php?route=signup
RewriteRule ^sitemap&p=([0-9]+)$ index.php?route=html&p=$1
RewriteRule ^([a-z0-9-]+)$ index.php?route=categories
RewriteRule ^([a-z0-9-]+)&p=([0-9]+)$ index.php?route=categories&p=$1
RewriteRule ^sitemap.xml$ index.php?route=sitemap
RewriteRule ^sitemap_([0-9]+).xml$ index.php?route=sitemap&p=$1
RewriteRule ^(?:[a-z0-9-]+/)?(.*)\.html$ index.php?page=$1

I cant understand the rewrite rules for lighttpd
I did this:

url.rewrite-if-not-file = ("^/page=([0-9]+)$" => "/index.php?cat=$1&$2")
url.rewrite-once = (
"^/admin$" => "/admin.php",
"^/sitemap$" => "/index.php?route=html",
"^/login$" => "/index.php?route=login",
"^/signup$" => "/index.php?route=signup",
"^/sitemap&p=([0-9]+)$" => "/index.php?route=html&p=$1",
"^/([a-z0-9-]+)$" => "/index.php?route=categories",
"^/([a-z0-9-]+)&p=([0-9]+)$" => "/index.php?route=categories&p=$1",
"^/sitemap\.xml$" => "/index.php?route=sitemap",
"^/sitemap_([0-9]+)\.xml$" => "/index.php?route=sitemap&p=$1",
"^/(?:[a-z0-9-]+/)?(.*)\.html$" => "/index.php?page=$1",
)

It doesn't work where the error do not understand, and where to read about it.


Replies (1)

RE: help convert apache htaccess [L,QSA] rewrite rules to lighttpd - Added by gstrauss 4 months ago

As an aside it might be easier if you just sent all those pages to index.php and parsed the URL there, and set the query string there, in your PHP.

It doesn't work where the error do not understand, and where to read about it.

Check the lighttpd error.log. Look in your config file for the location and name of the error log.

It doesn't work ...

No details means your problem is exactly as you stated "It doesn't work". What doesn't work? Do any of the URLs work as you expect? Would you provide an example of a request URL and what you expect to happen? Are all the pages you want to rewrite located in the top level of the URL path (e.g. /login) ?

url.rewrite-if-not-file = ("^/page=([0-9]+)$" => "/index.php?cat=$1&$2")
is wrong because you only have one pattern match, and so $2 is nothing.
Did you mean:
url.rewrite-if-not-file = ("^/page=([0-9]+)$" => "/index.php?cat=$1")

    (1-1/1)