Posted: Wed Apr 12, 2023 9:09 Post subject: Lighttpd and Pretty URLs.
I have been running Wordpress on DD-WRT successfully now for quite some time and I have been using lighttpd's mod_rewrite and the below code to achieve my pretty URLs.
However an issue I have is that the above acts for the whole folder served up by lighttpd, whereas ideally it would only be used on the wordpress site (eg I would like it to work for https://domain.com/wordpress and not the whole of https://domain.com)
instead, the rewrite only applies to that folder. It does still seem to grind to a stop though, which I can't quite work out. I will have a few more goes at rewriting my variables.
I also need to work out how to get it to exclude some of the directories within /wordpress/ for instance something along the lines of
Check the version of lighttpd that you are using and consider upgrading if the lighttp version is ancient.
Your regular expressions in url.rewrite are suspect.
"^/(wp-admin|wp-includes|wp-content)/(.*)" => "$0", is ignored for you because you have the url.rewrite inside the condition $HTTP["host"] =~ "/wordpress", and your regex does not match a string starting with /wordpress
What are you trying to rewrite? It would appear that you want to leave alone anything that contains a literal '.' followed by anything, and rewrite the rest. Based only on what you have posted above, try this:
Code:
$HTTP["url"] =~ "^/wordpress" {
url.rewrite = (
"^/wordpress/(?:wp-admin|wp-includes|wp-content)/" => "", # => "" no rewrite for these paths
"\.." => "", # => "" no rewrite for these paths
"" => "/wordpress/index.php${url.path}${qsa}" # rewrite everything else
)
}