Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

lighttpd add trailing slash.

Posted on 2009-05-03
6
Medium Priority
?
2,006 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 2000 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

Plesk WordPress Toolkit

Plesk's WordPress Toolkit allows server administrators, resellers and customers to manage their WordPress instances, enabling a variety of development workflows for WordPress admins of all skill levels, from beginners to pros.

See why 2/3 of Plesk servers use it.

Question has a verified solution.

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

Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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.
Suggested Courses

722 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