0

Here's the mod_rewrite .htaccess file which is meant to work on Apache Servers for my web-app

RewriteEngine On
RewriteBase /cs200/tokens/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [QSA,L]

These are some relevant $_SERVER parameters which may be useful.

$_SERVER["REQUEST_URI"]-    /cs200/tokens/
$_SERVER["DOCUMENT_ROOT"]-  /var/www/servers/www
$_SERVER["SCRIPT_FILENAME"]-    /var/www/servers/www/cs200/tokens/index.php
$_SERVER["PHP_SELF"] - /cs200/tokens/index.php

I have a lighttpd server in which I want to implement the same functionality of this .htaccess file. I have referred to a lot of sources online and came up with these. But none of them actually work. Let's say my domain name is www.example.com. I've tried the following examples and none of these do the trick

$HTTP["host"] =~ "www.example.com" {

url.rewrite-once = (
    "^/cs200/tokens(.*)" => "/index.php" 
)
}

example 2

$HTTP["host"] =~ "www.example.com" {

url.rewrite-once = (
    "^/cs200/tokens/(.*)" => "/cs200/tokens/index.php" 
)
}

None of these seem to be doing the functionality of this apache .htaccess file on lighttpd. This issue has been bugging me for the past 12 hours and I've sort of want to give up on this issue. Can anyone please help me?

P.S my Lighttpd Server version is 1.4.39

1 Answer 1

0

Ok so I figured it out anyways. This is for anyone who happens to stumble upon this issue. mod_rewrite in lighttpd is by default disabled in the configuration and has to be uncommented in lighttpd.conf at the beginning

server.modules = (
"mod_access",
"mod_alias",
"mod_compress",
"mod_redirect",
"mod_simple_vhost",
"mod_setenv",
    #"mod_rewrite", //remove the hash here

)

Also the regex for the above condition that worked for me is this

url.rewrite-once = (
    "^/cs200/tokens(.*)" => "/cs200/tokens/index.php" 

Also this should be added under

$HTTP["host"] =~ "www.example.com"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .