C
C
cdmax20022014-09-14 20:07:15
Apache HTTP Server
cdmax2002, 2014-09-14 20:07:15

How to convert apache .htaccess to lighttpd?

There is a .htaccess file. Apache works. When ported to lighttpd, no.

# Enable rewrite engine and route requests to framework
RewriteEngine On

# Some servers require you to specify the `RewriteBase` directive
# In such cases, it should be the path (relative to the document root)
# containing this .htaccess file
#
# RewriteBase /

RewriteCond %{REQUEST_URI} \.ini$
RewriteRule \.ini$ - [R=404]

RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L,QSA]
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]

As far as I understand .htaccess is not supported in lighttpd and you need to write everything in lighttpd.conf.
server.modules = ( "mod_access", "mod_rewrite" )
I registered it in lighttpd.conf.
In my understanding, the first two lines prohibit access to ini files, and I don’t understand what is written next.
I ask you to help convert the config file. And explain what these lines mean.
update:
Found that you can do this:
$HTTP["host"] =~ "www\.example\.com$" {
    url.rewrite-once = ( "^/(.*?)(\?.+)?$"=>"/index.php/$1?$2" )
    server.error-handler-404 = "/index.php"
}

Works, but processes all requests to the server. Those. stop loading css and js from /css and /js folders. How to make css and js load?
update2:
Rewrote the rule like this:
$HTTP["host"] =~ "www\.example\.com$" {
    url.rewrite-if-not-file = ( "^/(.*?)(\?.+)?$"=>"/index.php/$1?$2" )
    server.error-handler-404 = "/index.php"
}

Works as it should. But I'm not at all sure that this is equivalent to the condition described at the beginning. If someone can help, I'll be grateful.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question