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
Solved

lighttpd add trailing slash.

Posted on 2009-05-03
6
1,950 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: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

In this blog, I will share you some basic tips for content marketing and to rank your website on Google.
There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
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 viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

840 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