Results 1 to 11 of 11
  1. #1
    Join Date
    May 2007
    Posts
    33

    Unhappy convert .htaccess file ( apache to lighttpd )

    Hi,
    How to convert this .htaccess file to lighttpd rewrite rule ?
    Code:
    DirectoryIndex index.php
    
    RewriteEngine On
    
    RewriteCond %{REQUEST_URI} ^/uploads/fotos/*.*
    RewriteCond %{REQUEST_FILENAME} !-f
    #RewriteRule ^.*$ /notfound [L,N]
    RewriteRule ^.*$ /notfound [QSA,L,R=301]
    
    RewriteRule ^page/(.*)$ index.php?cstart=$1 [L]
    
    
    RewriteRule ^([0-9]{4})/([0-9]{2})/([0-9]{2})/page,([0-9]+),([0-9]+),(.*).html(/?)+$ index.php?subaction=showfull&year=$1&month=$2&day=$3&news_page=$4&cstart=$5&news_name=$6 [L]
    RewriteRule ^([0-9]{4})/([0-9]{2})/([0-9]{2})/page,([0-9]+),(.*).html(/?)+$ index.php?subaction=showfull&year=$1&month=$2&day=$3&news_page=$4&news_name=$5 [L]
    RewriteRule ^([0-9]{4})/([0-9]{2})/([0-9]{2})/print:page,([0-9]+),(.*).html(/?)+$ engine/print.php?subaction=showfull&year=$1&month=$2&day=$3&news_page=$4&news_name=$5 [L]
    RewriteRule ^([0-9]{4})/([0-9]{2})/([0-9]{2})/(.*).html(/?)+$ index.php?subaction=showfull&year=$1&month=$2&day=$3&news_name=$4 [L]
    
    RewriteRule ^([^.]+)/page,([0-9]+),([0-9]+),([0-9]+)-(.*).html(/?)+$ index.php?newsid=$4&news_page=$2&cstart=$3 [L]
    RewriteRule ^([^.]+)/page,([0-9]+),([0-9]+)-(.*).html(/?)+$ index.php?newsid=$3&news_page=$2 [L]
    RewriteRule ^([^.]+)/print:page,([0-9]+),([0-9]+)-(.*).html(/?)+$ engine/print.php?news_page=$2&newsid=$3 [L]
    RewriteRule ^([^.]+)/([0-9]+)-(.*).html(/?)+$ index.php?newsid=$2 [L]
    
    RewriteRule ^page,([0-9]+),([0-9]+),([0-9]+)-(.*).html(/?)+$ index.php?newsid=$3&news_page=$1&cstart=$2 [L]
    RewriteRule ^page,([0-9]+),([0-9]+)-(.*).html(/?)+$ index.php?newsid=$2&news_page=$1 [L]
    RewriteRule ^print:page,([0-9]+),([0-9]+)-(.*).html(/?)+$ engine/print.php?news_page=$1&newsid=$2 [L]
    RewriteRule ^([0-9]+)-(.*).html(/?)+$ index.php?newsid=$1 [L]
    
    
    RewriteRule ^([0-9]{4})/([0-9]{2})/([0-9]{2})(/?)+$ index.php?year=$1&month=$2&day=$3 [L]
    RewriteRule ^([0-9]{4})/([0-9]{2})/([0-9]{2})/page/([0-9]+)(/?)+$ index.php?year=$1&month=$2&day=$3&cstart=$4 [L]
    
    RewriteRule ^([0-9]{4})/([0-9]{2})(/?)+$ index.php?year=$1&month=$2 [L]
    RewriteRule ^([0-9]{4})/([0-9]{2})/page/([0-9]+)(/?)+$ index.php?year=$1&month=$2&cstart=$3 [L]
    
    RewriteRule ^([0-9]{4})(/?)+$ index.php?year=$1 [L]
    RewriteRule ^([0-9]{4})/page/([0-9]+)(/?)+$ index.php?year=$1&cstart=$2 [L]
    
    RewriteRule ^tags/([^/]*)(/?)+$ index.php?do=tags&tag=$1 [L]
    RewriteRule ^tags/([^/]*)/page/([0-9]+)(/?)+$ index.php?do=tags&tag=$1&cstart=$2 [L]
    
    RewriteRule ^user/([^/]*)/rss.xml$ engine/rss.php?subaction=allnews&user=$1 [L]
    RewriteRule ^user/([^/]*)(/?)+$ index.php?subaction=userinfo&user=$1 [L]
    RewriteRule ^user/([^/]*)/page/([0-9]+)(/?)+$ index.php?subaction=userinfo&user=$1&cstart=$2 [L]
    RewriteRule ^user/([^/]*)/news(/?)+$ index.php?subaction=allnews&user=$1 [L]
    RewriteRule ^user/([^/]*)/news/page/([0-9]+)(/?)+$ index.php?subaction=allnews&user=$1&cstart=$2 [L]
    RewriteRule ^user/([^/]*)/news/rss.xml(/?)+$ engine/rss.php?subaction=allnews&user=$1 [L]
    
    RewriteRule ^lastnews/(/?)+$ index.php?do=lastnews [L]
    RewriteRule ^lastnews/page/([0-9]+)(/?)+$ index.php?do=lastnews&cstart=$1 [L]
    
    RewriteRule ^catalog/([^/]*)(/?)+$ index.php?catalog=$1 [L]
    RewriteRule ^catalog/([^/]*)/page/([0-9]+)(/?)+$ index.php?catalog=$1&cstart=$2 [L]
    
    RewriteRule ^newposts(/?)+$ index.php?subaction=newposts [L]
    RewriteRule ^newposts/page/([0-9]+)(/?)+$ index.php?subaction=newposts&cstart=$1 [L]
    
    RewriteRule ^static/(.*).html(/?)+$ index.php?do=static&page=$1 [L]
    
    RewriteRule ^favorites(/?)+$ index.php?do=favorites [L]
    RewriteRule ^favorites/page/([0-9]+)(/?)+$ index.php?do=favorites&cstart=$1 [L]
    
    
    RewriteRule ^rules.html$ index.php?do=rules [L]
    RewriteRule ^dmca-policy.html$ dmca-policy.html [L]
    RewriteRule ^statistics.html$ index.php?do=stats [L]
    RewriteRule ^addnews.html$ index.php?do=addnews [L]
    RewriteRule ^rss.xml$ engine/rss.php [L]
    RewriteRule ^sitemap.xml$ sitemap.xml [L]
    RewriteRule ^google9f559184ca0e96de.html$ google9f559184ca0e96de.html [L]
    
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([^.]+)/page/([0-9]+)(/?)+$ index.php?do=cat&category=$1&cstart=$2 [L]
    RewriteCond %{REQUEST_URI} !^/notfound
    RewriteRule ^([^.]+)/?$ index.php?do=cat&category=$1 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^<]+)/rss.xml$ engine/rss.php?do=cat&category=$1 [L]
    RewriteRule ^page,([0-9]+),([^/]+).html$ index.php?do=static&page=$2&news_page=$1 [L]
    RewriteRule ^print:([^/]+).html$ engine/print.php?do=static&page=$1 [L]
    RewriteRule ^([^/]+)\.html$ index.php?do=static&page=$1 [L]
    Would appreciate this very much, thanks in advance

  2. #2
    Join Date
    May 2007
    Posts
    33
    Nobody help me? =(

  3. #3
    Join Date
    Nov 2001
    Location
    Vancouver
    Posts
    2,416
    I doubt anyone is going to wade through all those rules. Maybe one or two. Not 22.

    If your application is so messed up that you need that many rules (or have switched apps and are preserving SEO) it is time for you to learn how to do this!
    “Even those who arrange and design shrubberies are under
    considerable economic stress at this period in history.”

  4. #4
    Put these rules in the required virtual host block of lighttpd configuration file and restart lighttpd.

    "^page/(.*)$" => "/index.php?cstart=$1",
    "^([0-9]{4})/([0-9]{2})/([0-9]{2})/page,([0-9]+),([0-9]+),(.*).html(/?)+$" => "/index.php?subaction=showfull&year=$1&month=$2&day=$3&news_page=$4&cstart=$5&news_name=$6",
    "^([0-9]{4})/([0-9]{2})/([0-9]{2})/page,([0-9]+),(.*).html(/?)+$" => "/index.php?subaction=showfull&year=$1&month=$2&day=$3&news_page=$4&news_name=$5",
    "^([0-9]{4})/([0-9]{2})/([0-9]{2})/print:page,([0-9]+),(.*).html(/?)+$" => "/engine/print.php?subaction=showfull&year=$1&month=$2&day=$3&news_page=$4&news_name=$5",
    "^([0-9]{4})/([0-9]{2})/([0-9]{2})/(.*).html(/?)+$" => "/index.php?subaction=showfull&year=$1&month=$2&day=$3&news_name=$4",
    "^([^.]+)/page,([0-9]+),([0-9]+),([0-9]+)-(.*).html(/?)+$" => "/index.php?newsid=$4&news_page=$2&cstart=$3",
    "^([^.]+)/page,([0-9]+),([0-9]+)-(.*).html(/?)+$" => "/index.php?newsid=$3&news_page=$2",
    "^([^.]+)/print:page,([0-9]+),([0-9]+)-(.*).html(/?)+$" => "/engine/print.php?news_page=$2&newsid=$3",
    "^([^.]+)/([0-9]+)-(.*).html(/?)+$" => "/index.php?newsid=$2",
    "^page,([0-9]+),([0-9]+),([0-9]+)-(.*).html(/?)+$" => "/index.php?newsid=$3&news_page=$1&cstart=$2",
    "^page,([0-9]+),([0-9]+)-(.*).html(/?)+$" => "/index.php?newsid=$2&news_page=$1",
    "^print:page,([0-9]+),([0-9]+)-(.*).html(/?)+$" => "/engine/print.php?news_page=$1&newsid=$2",
    "^([0-9]+)-(.*).html(/?)+$" => "/index.php?newsid=$1",
    "^([0-9]{4})/([0-9]{2})/([0-9]{2})(/?)+$" => "/index.php?year=$1&month=$2&day=$3",
    "^([0-9]{4})/([0-9]{2})/([0-9]{2})/page/([0-9]+)(/?)+$" => "/index.php?year=$1&month=$2&day=$3&cstart=$4",
    "^([0-9]{4})/([0-9]{2})(/?)+$" => "/index.php?year=$1&month=$2",
    "^([0-9]{4})/([0-9]{2})/page/([0-9]+)(/?)+$" => "/index.php?year=$1&month=$2&cstart=$3",
    "^([0-9]{4})(/?)+$" => "/index.php?year=$1",
    "^([0-9]{4})/page/([0-9]+)(/?)+$" => "/index.php?year=$1&cstart=$2",
    "^tags/([^/]*)(/?)+$" => "/index.php?do=tags&tag=$1",
    "^tags/([^/]*)/page/([0-9]+)(/?)+$" => "/index.php?do=tags&tag=$1&cstart=$2",
    "^user/([^/]*)/rss.xml$" => "/engine/rss.php?subaction=allnews&user=$1",
    "^user/([^/]*)(/?)+$" => "/index.php?subaction=userinfo&user=$1",
    "^user/([^/]*)/page/([0-9]+)(/?)+$" => "/index.php?subaction=userinfo&user=$1&cstart=$2",
    "^user/([^/]*)/news(/?)+$" => "/index.php?subaction=allnews&user=$1",
    "^user/([^/]*)/news/page/([0-9]+)(/?)+$" => "/index.php?subaction=allnews&user=$1&cstart=$2",
    "^user/([^/]*)/news/rss.xml(/?)+$" => "/engine/rss.php?subaction=allnews&user=$1",
    "^lastnews/(/?)+$" => "/index.php?do=lastnews",
    "^lastnews/page/([0-9]+)(/?)+$" => "/index.php?do=lastnews&cstart=$1",
    "^catalog/([^/]*)(/?)+$" => "/index.php?catalog=$1",
    "^catalog/([^/]*)/page/([0-9]+)(/?)+$" => "/index.php?catalog=$1&cstart=$2",
    "^newposts(/?)+$" => "/index.php?subaction=newposts",
    "^newposts/page/([0-9]+)(/?)+$" => "/index.php?subaction=newposts&cstart=$1",
    "^static/(.*).html(/?)+$" => "/index.php?do=static&page=$1",
    "^favorites(/?)+$" => "/index.php?do=favorites",
    "^favorites/page/([0-9]+)(/?)+$" => "/index.php?do=favorites&cstart=$1",
    "^rules.html$" => "/index.php?do=rules",
    "^dmca-policy.html$" => "/dmca-policy.html",
    "^statistics.html$" => "/index.php?do=stats",
    "^addnews.html$" => "/index.php?do=addnews",
    "^rss.xml$" => "/engine/rss.php",
    "^sitemap.xml$" => "/sitemap.xml",
    "^google9f559184ca0e96de.html$" => "/google9f559184ca0e96de.html",
    "%{REQUEST_FILENAME}" => "/!-d",
    "^([^.]+)/page/([0-9]+)(/?)+$" => "/index.php?do=cat&category=$1&cstart=$2",
    "%{REQUEST_URI}" => "/!^/notfound",
    "^([^.]+)/?$" => "/index.php?do=cat&category=$1",
    "%{REQUEST_FILENAME}" => "/!-f",
    "^([^<]+)/rss.xml$" => "/engine/rss.php?do=cat&category=$1",
    "^page,([0-9]+),([^/]+).html$" => "/index.php?do=static&page=$2&news_page=$1",
    "^print[^/]+).html$" => "/engine/print.php?do=static&page=$1",
    "^([^/]+)\.html$" => "/index.php?do=static&page=$1",

  5. #5
    All rules should be given in the directive url.rewrite=()
    For example,
    url.rewrite=(
    rule 1,
    rule 2,
    ------,
    ------,
    rule n)

  6. #6
    Join Date
    May 2007
    Posts
    33
    Hi sreeji,
    Thanks for your great help. Can you please put this code between code tag ?

    Regards

  7. #7
    These rules are used only in lighttpd "url.rewrite" directive. I don't understand why you want these rules in HTML code tag.

  8. #8
    Join Date
    May 2007
    Posts
    33
    Quote Originally Posted by sreeji View Post
    These rules are used only in lighttpd "url.rewrite" directive. I don't understand why you want these rules in HTML code tag.
    Dear sreeji,
    I think you don't understand my mean. I want that you put this code between "[code]" here ( like my first post ) because some characters convert to smily.

  9. #9
    Join Date
    Mar 2008
    Posts
    372
    mate u can convert them, only 1 tag was converted into smiley
    and it was : ( , u should check them manually,

  10. #10
    Join Date
    May 2007
    Posts
    33
    Well, i test this code but unfortunately doesn't work. I think that you don't use some command here such as url.rewrite-repeat orurl.rewrite-once ...

    Please check the below link:
    http://redmine.lighttpd.net/wiki/lig...ocs:ModRewrite

  11. #11
    Yes, you could use url.rewrite-once in lieu of url.rewrite. But I am not sure about the following rules:

    "%{REQUEST_URI}" => "/!^/notfound",
    "%{REQUEST_FILENAME}" => "/!-f",
    Please remove these rules from the required virtual host block.

    Also I didn't convert the following htaccess rules:

    RewriteCond %{REQUEST_URI} ^/uploads/fotos/*.*
    RewriteCond %{REQUEST_FILENAME} !-f
    #RewriteRule ^.*$ /notfound [L,N]
    RewriteRule ^.*$ /notfound [QSA,L,R=301]

    All rules except the rules I mentioned above should work with url.rewrite-once and url.rewrite.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •