Solved

lighttpd add trailing slash.

Posted on 2009-05-03
6
1,938 Views
Last Modified: 2012-05-06
Hi Experts,
i want to convert my mod_rewrite rules from apache to a rewrite rule for lightttpd.
All my rewrite rules work fine. But how can i check for a condition in lightttpd.
I need to put a slash at the end of each url.

In Apache i use:
RewriteCond %{REQUEST_URI} ^/[^\.]+[^/]$
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1/ [R=301,L]

now when i try:
url.rewrite-once = ("^(.*)$" => "http://%{HTTP_HOST}/$1/")

it doesnt work. is there a way in lighttpd to put a slash at the ent of url if not exist?
0
Comment
Question by:bibabutze
  • 3
  • 2
6 Comments
 
LVL 4

Expert Comment

by:trencH87
ID: 24290599
Make sure mod_rewrite is enabled - "server.modules += ( "mod_rewrite" )" and use this line:
url.rewrite-once = (

        "^(/.*)$" => "/$1/",

)

Open in new window

0
 

Author Comment

by:bibabutze
ID: 24291079
i think of something like redirect. So if there is no slash at the end the page is redirect to the page with the slash at the end.
i tried this
$HTTP["host"] =~ "/[^\.]+[^/]" {
  url.redirect             = ( "^/(.*)" => "http://%1/$1/" )
}
 but it doesn´t work
0
 
LVL 4

Accepted Solution

by:
trencH87 earned 500 total points
ID: 24382403
Lighttpd doesn't have this trailing slash problem in the latest release. Maybe you should try upgrading yours ? The line I gave you should do the trick though. url.rewrite is redirecting(or fixing if you will) the user to the chosen page with a trailing slash. No need to url.redirect it. Try the code in your lighttpd config.
url.rewrite-once = (

        "^(/.*)$" => "/$1/"

)

Open in new window

0
 

Author Comment

by:bibabutze
ID: 24382465
i still have one problem with your rule.
www.mypage.com/mytest
www.mypage.com/mytest/
both links are working, But the last slash is not displayed in the url.
This will lead to duplicate content for google and other searchengines.
So is there a simple way with lighttpd like in apache to display always a slash at the end.
 
0
 

Author Comment

by:bibabutze
ID: 24816043
does anybody else have an idea how to solve this
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Your personal information, where you live, your wedding information, and anything else personal may be located online and in many cases the aggregators who pulled this stuff did so without your permission. Here are ways that you can get rid of unwan…
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now