Solved

lighttpd add trailing slash.

Posted on 2009-05-03
6
1,956 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Google Analytics setup 5 68
warning code: class php incomplete message 6 30
auto play video on web page 4 39
ASP.NET data base connection 35 34
When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
With more and more people tethered to the internet, advertisers can reach you in new and creative ways. Push notifications on your smartphone, customized advertisements based on your previous searches, and email inboxes filled with promotional pitch…
The viewer will learn how to dynamically set the form action using jQuery.
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.

762 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