Project

General

Profile

Directives url.rewrite-if-not-file and index-file-names not working in 1.4.56

Added by maxentry over 3 years ago

I had this working in 1.4.55 but I am now unable to browse to a path without an explicit file name. Here is what I have:

url.rewrite-if-not-file = ( "^/(.)(\?.)?$" => "/index.html?fwd=$1" )
index-file.names            = ( "index.php", "index.html", "index.lighttpd.html" )

When I click on a link, I get this (and then have to add the file name, index.html for the page to show)


Replies (7)

RE: Directives url.rewrite-if-not-file and index-file-names not working in 1.4.56 - Added by gstrauss over 3 years ago

url.rewrite-if-not-file = ( "^/(.)(\?.)?$" => "/index.html?fwd=$1" )

The regex looks a bit suspect, as (.) matches a single character and (\?.)? matches an optional ("?" and single character).
Did you mean .* instead of . ?

RE: Directives url.rewrite-if-not-file and index-file-names not working in 1.4.56 - Added by maxentry over 3 years ago

I suspected the regex but have just tried:

url.rewrite-if-not-file = ( "^/(.*)(\?.)?$" => "/index.html?fwd=$1" )

and
url.rewrite-if-not-file = ( "^/(.*)(\?.*)?$" => "/index.html?fwd=$1" )

Both no luck!
This happens when I click on an html link written as:

<a href="/">Home</a>

PS: When I hover over the link in a browser, it shows as pointing to https://mysite.com/ and when I click the link the browser shows the location to be https://mysite.com and displays the mage abpve.

RE: Directives url.rewrite-if-not-file and index-file-names not working in 1.4.56 - Added by gstrauss over 3 years ago

This does not sound like a problem in lighttpd. You have demonstrated sloppy configuration change management, and you very likely changed more than one thing at once. Go back to a working configuration and change one thing at a time.

RE: Directives url.rewrite-if-not-file and index-file-names not working in 1.4.56 - Added by maxentry over 3 years ago

Thanks for the feedback.
may I just say, I changed to one then the other - did not change anything else - first added the * to first brackets, restarted lighttpd, reloaded page and tested link, then added second * to second set of brackets, reloaded lighttpd, refreshed page then clicked link - both with the same result.
PS: I firstly downloaded and compiled rc7 then after I encountered the bug with maxminddb.env configuration setting, downloaded and compiled from your master branch after you fixed the bug

RE: Directives url.rewrite-if-not-file and index-file-names not working in 1.4.56 - Added by gstrauss over 3 years ago

I had this working in 1.4.55

Let me just say url.rewrite-if-not-file = ( "^/(.)(\?.)?$" => "/index.html?fwd=$1" ) never applied to <a href="/">, so if things worked for you in lighttpd 1.4.55, this wasn't part of what was working.

RE: Directives url.rewrite-if-not-file and index-file-names not working in 1.4.56 - Added by maxentry over 3 years ago

Funny you mention that - I have just tested 1.4.55 before I even read the above comment and it still works! The only difference in the configuration is the (for 1.4.55) index-file.name += ("index.html")
Anyway, I will not annoy you anymore with this, if I cannot get it to work I'll just have to edit all links to explicitly point to /index.html rather than /

RE: Directives url.rewrite-if-not-file and index-file-names not working in 1.4.56 - Added by gstrauss over 3 years ago

My annoyance stems from you making poor assumptions, making poorly supported (and incorrect) statements, and in you not providing good observational information.

My words above were precise. The url.rewrite-if-not-file regex never applied to "/". If things worked for "/", it was because of other parts of your configuration (likely index-file.names), but you have not shared your entire config.

Please carefully read How to get support

Then re-read your title of this post: "Directives url.rewrite-if-not-file and index-file-names not working in 1.4.56"

url.rewrite-if-not-file works just fine. Your understanding of regexes is poor, and more importantly, your skills are lacking when it comes to testing and verifying the changes you make to your configuration. Again, see your regex, which you assumed (incorrectly) was working, and assumed (incorrectly) that url.rewrite-if-not-file stopped working in lighttpd 1.4.56. (Again, see that title you gave this post.)

My responses in this post are directly related to the (limited) information provided: the statement "Directives url.rewrite-if-not-file and index-file-names not working in 1.4.56" and the two configuration lines you posted, one which contained a strange regex which I flagged as such.

    (1-7/7)