Project

General

Profile

help convert apache htaccess rewrite rules to lighttpd

Added by pdw over 11 years ago

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

RewriteBase /
RewriteCond %{REQUEST_URI} ^(.+)\~s$
RewriteRule ^(.*) stats.php?u=$1 [L]
RewriteCond %{REQUEST_URI} ^(.+)\~d$
RewriteRule ^(.*) delete_file.php?u=$1 [QSA,L]
RewriteCond %{REQUEST_URI} ^(.+)\~i$
RewriteRule ^(.*) share_file.php?u=$1 [QSA,L]
RewriteCond %{REQUEST_URI} ^(.+)\~f$
RewriteRule ^(.*) view_folder.php?f=$1 [QSA,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !\.html$
RewriteRule ^(.*) file_download.php?u=$1 [QSA,L]

RewriteRule ^(.*).html$ $1.php [QSA,L]

ive been reading the forums and many websites, but I cant understand the rewrite rules for lighttpd

Here is what I managed to do until now :

server.error-handler-404 = "/index.php" 
url.rewrite-once = (
    "^(.*).html$" => "$1.php",
    "^/([^./]+)$"    => "/file_download.php?u=$1",
)

but I dont know how to add other rules... if I had

"^/([^./]+)$"    => "/stats.php?u=$1"

Then lighttpd won't start, seems it's a duplicate entry...

Please help me to manage this.. Thanks..


Replies (4)

RE: help convert apache htaccess rewrite rules to lighttpd - Added by patrickdk over 11 years ago

url.rewrite-once = (
"^(.*)\~s$" => "/stats.php?u=$1",
"^(.*)\~d$" => "/delete_file.php?u=$1",
"^(.*)\~i$" => "/share_file.php?u=$1",
"^(.*)\~f$" => "/view_folder.php?f=$1"
)

The file_download.php will require a mod_magnet lua script, and since the last one depends on that, both will need to be using magnet

You could also just do all of it in the magnet script to keep it all together also.

RE: help convert apache htaccess rewrite rules to lighttpd - Added by pdw over 11 years ago

Thanks for the answer, i'm not very good with these things ...
I put the rules you said.

I installed mod_magnet, now, what do i need to do to set these rewrite rules with mod_magnet?

Also, it seems that the variables in URI are not working

Like, this URL : http://www.mysite.com/rs~i?10f8038573d68caa415ce32712619040 doesnt call anything, and just go to index.html
also, this URL : http://www.mysite.com/register.html?f=rt is just going to index.html

everything that is after the ? in the URI does not work...

Any help welcome, thanks.

RE: help convert apache htaccess rewrite rules to lighttpd - Added by pdw over 11 years ago

I think the problem with query string is in this line :

RewriteRule ^(.*).html$ $1.php [QSA,L]

How do i convert that QSA thing into lighttpd rules, so that query strings work ?

Thanks..

RE: help convert apache htaccess rewrite rules to lighttpd - Added by patrickdk over 11 years ago

url.rewrite-once = (
"^(.*)\~s(\?,*)$" => "/stats.php?u=$1",
"^(.*)\~d(\?,*)$" => "/delete_file.php?u=$1",
"^(.*)\~i(\?,*)$" => "/share_file.php?u=$1",
"^(.*)\~f(\?,*)$" => "/view_folder.php?f=$1"
)

Will fix that issue.

the html to php rewrite while it will work, wont work correctly, cause the one before it has a file and directory conditional, that lighttpd does not support without using mod_magnet.

Adding a "^(.*)\.html$" => "$1.php" will do it, but it won't work correctly 100% cause your missing the previous conditional one.

    (1-4/4)