Solved

lighttpd add trailing slash.

Posted on 2009-05-03
6
1,982 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Get proactive database performance tuning online

At Percona’s web store you can order full Percona Database Performance Audit in minutes. Find out the health of your database, and how to improve it. Pay online with a credit card. Improve your database performance now!

Question has a verified solution.

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

Dramatic changes are revolutionizing how we build and use technology. Every company is automating, digitizing, and modernizing operations. We need a better, more connected way to work together as teams so we can harness the insights from our system…
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

632 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